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.Exclusion;
026
027/**
028 * The management updates to apply to a dependency.
029 * 
030 * @see DependencyManager#manageDependency(org.eclipse.aether.graph.Dependency)
031 */
032public final class DependencyManagement
033{
034
035    private String version;
036
037    private String scope;
038
039    private Boolean optional;
040
041    private Collection<Exclusion> exclusions;
042
043    private Map<String, String> properties;
044
045    /**
046     * Creates an empty management update.
047     */
048    public DependencyManagement()
049    {
050        // enables default constructor
051    }
052
053    /**
054     * Gets the new version to apply to the dependency.
055     * 
056     * @return The new version or {@code null} if the version is not managed and the existing dependency version should
057     *         remain unchanged.
058     */
059    public String getVersion()
060    {
061        return version;
062    }
063
064    /**
065     * Sets the new version to apply to the dependency.
066     * 
067     * @param version The new version, may be {@code null} if the version is not managed.
068     * @return This management update for chaining, never {@code null}.
069     */
070    public DependencyManagement setVersion( String version )
071    {
072        this.version = version;
073        return this;
074    }
075
076    /**
077     * Gets the new scope to apply to the dependency.
078     * 
079     * @return The new scope or {@code null} if the scope is not managed and the existing dependency scope should remain
080     *         unchanged.
081     */
082    public String getScope()
083    {
084        return scope;
085    }
086
087    /**
088     * Sets the new scope to apply to the dependency.
089     * 
090     * @param scope The new scope, may be {@code null} if the scope is not managed.
091     * @return This management update for chaining, never {@code null}.
092     */
093    public DependencyManagement setScope( String scope )
094    {
095        this.scope = scope;
096        return this;
097    }
098
099    /**
100     * Gets the new optional flag to apply to the dependency.
101     * 
102     * @return The new optional flag or {@code null} if the flag is not managed and the existing optional flag of the
103     *         dependency should remain unchanged.
104     */
105    public Boolean getOptional()
106    {
107        return optional;
108    }
109
110    /**
111     * Sets the new optional flag to apply to the dependency.
112     * 
113     * @param optional The optional flag, may be {@code null} if the flag is not managed.
114     * @return This management update for chaining, never {@code null}.
115     */
116    public DependencyManagement setOptional( Boolean optional )
117    {
118        this.optional = optional;
119        return this;
120    }
121
122    /**
123     * Gets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
124     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
125     * with information from dependency management or overridden by it.
126     * 
127     * @return The new exclusions or {@code null} if the exclusions are not managed and the existing dependency
128     *         exclusions should remain unchanged.
129     */
130    public Collection<Exclusion> getExclusions()
131    {
132        return exclusions;
133    }
134
135    /**
136     * Sets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
137     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
138     * with information from dependency management or overridden by it.
139     * 
140     * @param exclusions The new exclusions, may be {@code null} if the exclusions are not managed.
141     * @return This management update for chaining, never {@code null}.
142     */
143    public DependencyManagement setExclusions( Collection<Exclusion> exclusions )
144    {
145        this.exclusions = exclusions;
146        return this;
147    }
148
149    /**
150     * Gets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
151     * i.e. the dependency manager controls whether any existing properties get merged with the information from
152     * dependency management or overridden by it.
153     * 
154     * @return The new artifact properties or {@code null} if the properties are not managed and the existing properties
155     *         should remain unchanged.
156     */
157    public Map<String, String> getProperties()
158    {
159        return properties;
160    }
161
162    /**
163     * Sets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
164     * i.e. the dependency manager controls whether any existing properties get merged with the information from
165     * dependency management or overridden by it.
166     * 
167     * @param properties The new artifact properties, may be {@code null} if the properties are not managed.
168     * @return This management update for chaining, never {@code null}.
169     */
170    public DependencyManagement setProperties( Map<String, String> properties )
171    {
172        this.properties = properties;
173        return this;
174    }
175
176}