View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2010, 2013 Sonatype, Inc.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *    Sonatype, Inc. - initial API and implementation
10   *******************************************************************************/
11  package org.eclipse.aether.collection;
12  
13  import java.util.Collection;
14  import java.util.Map;
15  
16  import org.eclipse.aether.graph.Dependency;
17  import org.eclipse.aether.graph.Exclusion;
18  
19  /**
20   * The management updates to apply to a dependency.
21   * 
22   * @see DependencyManager#manageDependency(Dependency)
23   */
24  public final class DependencyManagement
25  {
26  
27      private String version;
28  
29      private String scope;
30  
31      private Boolean optional;
32  
33      private Collection<Exclusion> exclusions;
34  
35      private Map<String, String> properties;
36  
37      /**
38       * Creates an empty management update.
39       */
40      public DependencyManagement()
41      {
42          // enables default constructor
43      }
44  
45      /**
46       * Gets the new version to apply to the dependency.
47       * 
48       * @return The new version or {@code null} if the version is not managed and the existing dependency version should
49       *         remain unchanged.
50       */
51      public String getVersion()
52      {
53          return version;
54      }
55  
56      /**
57       * Sets the new version to apply to the dependency.
58       * 
59       * @param version The new version, may be {@code null} if the version is not managed.
60       * @return This management update for chaining, never {@code null}.
61       */
62      public DependencyManagement setVersion( String version )
63      {
64          this.version = version;
65          return this;
66      }
67  
68      /**
69       * Gets the new scope to apply to the dependency.
70       * 
71       * @return The new scope or {@code null} if the scope is not managed and the existing dependency scope should remain
72       *         unchanged.
73       */
74      public String getScope()
75      {
76          return scope;
77      }
78  
79      /**
80       * Sets the new scope to apply to the dependency.
81       * 
82       * @param scope The new scope, may be {@code null} if the scope is not managed.
83       * @return This management update for chaining, never {@code null}.
84       */
85      public DependencyManagement setScope( String scope )
86      {
87          this.scope = scope;
88          return this;
89      }
90  
91      /**
92       * Gets the new optional flag to apply to the dependency.
93       * 
94       * @return The new optional flag or {@code null} if the flag is not managed and the existing optional flag of the
95       *         dependency should remain unchanged.
96       */
97      public Boolean getOptional()
98      {
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     {
110         this.optional = optional;
111         return this;
112     }
113 
114     /**
115      * Gets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
116      * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
117      * with information from dependency management or overridden by it.
118      * 
119      * @return The new exclusions or {@code null} if the exclusions are not managed and the existing dependency
120      *         exclusions should remain unchanged.
121      */
122     public Collection<Exclusion> getExclusions()
123     {
124         return exclusions;
125     }
126 
127     /**
128      * Sets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
129      * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
130      * with information from dependency management or overridden by it.
131      * 
132      * @param exclusions The new exclusions, may be {@code null} if the exclusions are not managed.
133      * @return This management update for chaining, never {@code null}.
134      */
135     public DependencyManagement setExclusions( Collection<Exclusion> exclusions )
136     {
137         this.exclusions = exclusions;
138         return this;
139     }
140 
141     /**
142      * Gets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
143      * i.e. the dependency manager controls whether any existing properties get merged with the information from
144      * dependency management or overridden by it.
145      * 
146      * @return The new artifact properties or {@code null} if the properties are not managed and the existing properties
147      *         should remain unchanged.
148      */
149     public Map<String, String> getProperties()
150     {
151         return properties;
152     }
153 
154     /**
155      * Sets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
156      * i.e. the dependency manager controls whether any existing properties get merged with the information from
157      * dependency management or overridden by it.
158      * 
159      * @param properties The new artifact properties, may be {@code null} if the properties are not managed.
160      * @return This management update for chaining, never {@code null}.
161      */
162     public DependencyManagement setProperties( Map<String, String> properties )
163     {
164         this.properties = properties;
165         return this;
166     }
167 
168 }