001package org.eclipse.aether.collection;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 * 
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 * 
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Collection;
023import java.util.Map;
024
025import org.eclipse.aether.graph.Dependency;
026import org.eclipse.aether.graph.Exclusion;
027
028/**
029 * The management updates to apply to a dependency.
030 * 
031 * @see DependencyManager#manageDependency(Dependency)
032 */
033public final class DependencyManagement
034{
035
036    private String version;
037
038    private String scope;
039
040    private Boolean optional;
041
042    private Collection<Exclusion> exclusions;
043
044    private Map<String, String> properties;
045
046    /**
047     * Creates an empty management update.
048     */
049    public DependencyManagement()
050    {
051        // enables default constructor
052    }
053
054    /**
055     * Gets the new version to apply to the dependency.
056     * 
057     * @return The new version or {@code null} if the version is not managed and the existing dependency version should
058     *         remain unchanged.
059     */
060    public String getVersion()
061    {
062        return version;
063    }
064
065    /**
066     * Sets the new version to apply to the dependency.
067     * 
068     * @param version The new version, may be {@code null} if the version is not managed.
069     * @return This management update for chaining, never {@code null}.
070     */
071    public DependencyManagement setVersion( String version )
072    {
073        this.version = version;
074        return this;
075    }
076
077    /**
078     * Gets the new scope to apply to the dependency.
079     * 
080     * @return The new scope or {@code null} if the scope is not managed and the existing dependency scope should remain
081     *         unchanged.
082     */
083    public String getScope()
084    {
085        return scope;
086    }
087
088    /**
089     * Sets the new scope to apply to the dependency.
090     * 
091     * @param scope The new scope, may be {@code null} if the scope is not managed.
092     * @return This management update for chaining, never {@code null}.
093     */
094    public DependencyManagement setScope( String scope )
095    {
096        this.scope = scope;
097        return this;
098    }
099
100    /**
101     * Gets the new optional flag to apply to the dependency.
102     * 
103     * @return The new optional flag or {@code null} if the flag is not managed and the existing optional flag of the
104     *         dependency should remain unchanged.
105     */
106    public Boolean getOptional()
107    {
108        return optional;
109    }
110
111    /**
112     * Sets the new optional flag to apply to the dependency.
113     * 
114     * @param optional The optional flag, may be {@code null} if the flag is not managed.
115     * @return This management update for chaining, never {@code null}.
116     */
117    public DependencyManagement setOptional( Boolean optional )
118    {
119        this.optional = optional;
120        return this;
121    }
122
123    /**
124     * Gets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
125     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
126     * with information from dependency management or overridden by it.
127     * 
128     * @return The new exclusions or {@code null} if the exclusions are not managed and the existing dependency
129     *         exclusions should remain unchanged.
130     */
131    public Collection<Exclusion> getExclusions()
132    {
133        return exclusions;
134    }
135
136    /**
137     * Sets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
138     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
139     * with information from dependency management or overridden by it.
140     * 
141     * @param exclusions The new exclusions, may be {@code null} if the exclusions are not managed.
142     * @return This management update for chaining, never {@code null}.
143     */
144    public DependencyManagement setExclusions( Collection<Exclusion> exclusions )
145    {
146        this.exclusions = exclusions;
147        return this;
148    }
149
150    /**
151     * Gets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
152     * i.e. the dependency manager controls whether any existing properties get merged with the information from
153     * dependency management or overridden by it.
154     * 
155     * @return The new artifact properties or {@code null} if the properties are not managed and the existing properties
156     *         should remain unchanged.
157     */
158    public Map<String, String> getProperties()
159    {
160        return properties;
161    }
162
163    /**
164     * Sets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
165     * i.e. the dependency manager controls whether any existing properties get merged with the information from
166     * dependency management or overridden by it.
167     * 
168     * @param properties The new artifact properties, may be {@code null} if the properties are not managed.
169     * @return This management update for chaining, never {@code null}.
170     */
171    public DependencyManagement setProperties( Map<String, String> properties )
172    {
173        this.properties = properties;
174        return this;
175    }
176
177}