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