View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether.collection;
20  
21  import java.util.Collection;
22  import java.util.Map;
23  
24  import org.eclipse.aether.graph.Exclusion;
25  
26  /**
27   * The management updates to apply to a dependency.
28   *
29   * @see DependencyManager#manageDependency(org.eclipse.aether.graph.Dependency)
30   */
31  public final class DependencyManagement {
32  
33      private String version;
34  
35      private String scope;
36  
37      private Boolean optional;
38  
39      private Collection<Exclusion> exclusions;
40  
41      private Map<String, String> properties;
42  
43      /**
44       * Creates an empty management update.
45       */
46      public DependencyManagement() {
47          // enables default constructor
48      }
49  
50      /**
51       * Gets the new version to apply to the dependency.
52       *
53       * @return The new version or {@code null} if the version is not managed and the existing dependency version should
54       *         remain unchanged.
55       */
56      public String getVersion() {
57          return version;
58      }
59  
60      /**
61       * Sets the new version to apply to the dependency.
62       *
63       * @param version The new version, may be {@code null} if the version is not managed.
64       * @return This management update for chaining, never {@code null}.
65       */
66      public DependencyManagement setVersion(String version) {
67          this.version = version;
68          return this;
69      }
70  
71      /**
72       * Gets the new scope to apply to the dependency.
73       *
74       * @return The new scope or {@code null} if the scope is not managed and the existing dependency scope should remain
75       *         unchanged.
76       */
77      public String getScope() {
78          return scope;
79      }
80  
81      /**
82       * Sets the new scope to apply to the dependency.
83       *
84       * @param scope The new scope, may be {@code null} if the scope is not managed.
85       * @return This management update for chaining, never {@code null}.
86       */
87      public DependencyManagement setScope(String scope) {
88          this.scope = scope;
89          return this;
90      }
91  
92      /**
93       * Gets the new optional flag to apply to the dependency.
94       *
95       * @return The new optional flag or {@code null} if the flag is not managed and the existing optional flag of the
96       *         dependency should remain unchanged.
97       */
98      public Boolean getOptional() {
99          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 }