View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model.vm
3   //  template, any modifications will be overwritten.
4   // ==============================================================
5   package org.apache.maven.api.model;
6   
7   import java.io.Serializable;
8   import java.util.Collections;
9   import java.util.HashMap;
10  import java.util.Map;
11  import java.util.Set;
12  import org.apache.maven.api.annotations.Experimental;
13  import org.apache.maven.api.annotations.Generated;
14  import org.apache.maven.api.annotations.Immutable;
15  import org.apache.maven.api.annotations.Nonnull;
16  import org.apache.maven.api.annotations.NotThreadSafe;
17  import org.apache.maven.api.annotations.ThreadSafe;
18  
19  /**
20   * Information about the issue tracking (or bug tracking) system used to manage this
21   * project.
22   */
23  @Experimental
24  @Generated @ThreadSafe @Immutable
25  public class IssueManagement
26      implements Serializable, InputLocationTracker
27  {
28      /**
29       * The name of the issue management system, e.g. Bugzilla
30       */
31      final String system;
32      /**
33       * URL for the issue management system used by the project.
34       */
35      final String url;
36      /** Locations (this potentially hides the same name field from the super class) */
37      final Map<Object, InputLocation> locations;
38      /** Location tracking */
39      final InputLocation importedFrom;
40  
41      /**
42        * Constructor for this class, to be called from its subclasses and {@link Builder}.
43        * @see Builder#build()
44        */
45      protected IssueManagement(Builder builder) {
46          this.system = builder.system != null ? builder.system : (builder.base != null ? builder.base.system : null);
47          this.url = builder.url != null ? builder.url : (builder.base != null ? builder.base.url : null);
48          Map<Object, InputLocation> newlocs = builder.locations != null ? builder.locations : Collections.emptyMap();
49          Map<Object, InputLocation> oldlocs = builder.base != null && builder.base.locations != null ? builder.base.locations : Collections.emptyMap();
50          Map<Object, InputLocation> mutableLocations = new HashMap<>();
51          this.importedFrom = builder.importedFrom;
52          mutableLocations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
53          mutableLocations.put("system", newlocs.containsKey("system") ? newlocs.get("system") : oldlocs.get("system"));
54          mutableLocations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
55          this.locations = Collections.unmodifiableMap(mutableLocations);
56      }
57  
58      /**
59       * The name of the issue management system, e.g. Bugzilla
60       *
61       * @return a {@code String}
62       */
63      public String getSystem() {
64          return this.system;
65      }
66  
67      /**
68       * URL for the issue management system used by the project.
69       *
70       * @return a {@code String}
71       */
72      public String getUrl() {
73          return this.url;
74      }
75  
76      /**
77       * Gets the location of the specified field in the input source.
78       */
79      public InputLocation getLocation(Object key) {
80          return locations != null ? locations.get(key) : null;
81      }
82  
83      /**
84      * Gets the keys of the locations of the input source.
85      */
86      public Set<Object> getLocationKeys() {
87          return locations != null ? locations.keySet() : null;
88      }
89  
90      /**
91       * Gets the input location that caused this model to be read.
92       */
93      public InputLocation getImportedFrom()
94      {
95          return importedFrom;
96      }
97  
98      /**
99       * Creates a new builder with this object as the basis.
100      *
101      * @return a {@code Builder}
102      */
103     @Nonnull
104     public Builder with() {
105         return newBuilder(this);
106     }
107     /**
108      * Creates a new {@code IssueManagement} instance using the specified system.
109      *
110      * @param system the new {@code String} to use
111      * @return a {@code IssueManagement} with the specified system
112      */
113     @Nonnull
114     public IssueManagement withSystem(String system) {
115         return newBuilder(this, true).system(system).build();
116     }
117     /**
118      * Creates a new {@code IssueManagement} instance using the specified url.
119      *
120      * @param url the new {@code String} to use
121      * @return a {@code IssueManagement} with the specified url
122      */
123     @Nonnull
124     public IssueManagement withUrl(String url) {
125         return newBuilder(this, true).url(url).build();
126     }
127 
128     /**
129      * Creates a new {@code IssueManagement} instance.
130      * Equivalent to {@code newInstance(true)}.
131      * @see #newInstance(boolean)
132      *
133      * @return a new {@code IssueManagement}
134      */
135     @Nonnull
136     public static IssueManagement newInstance() {
137         return newInstance(true);
138     }
139 
140     /**
141      * Creates a new {@code IssueManagement} instance using default values or not.
142      * Equivalent to {@code newBuilder(withDefaults).build()}.
143      *
144      * @param withDefaults the boolean indicating whether default values should be used
145      * @return a new {@code IssueManagement}
146      */
147     @Nonnull
148     public static IssueManagement newInstance(boolean withDefaults) {
149         return newBuilder(withDefaults).build();
150     }
151 
152     /**
153      * Creates a new {@code IssueManagement} builder instance.
154      * Equivalent to {@code newBuilder(true)}.
155      * @see #newBuilder(boolean)
156      *
157      * @return a new {@code Builder}
158      */
159     @Nonnull
160     public static Builder newBuilder() {
161         return newBuilder(true);
162     }
163 
164     /**
165      * Creates a new {@code IssueManagement} builder instance using default values or not.
166      *
167      * @param withDefaults the boolean indicating whether default values should be used
168      * @return a new {@code Builder}
169      */
170     @Nonnull
171     public static Builder newBuilder(boolean withDefaults) {
172         return new Builder(withDefaults);
173     }
174 
175     /**
176      * Creates a new {@code IssueManagement} builder instance using the specified object as a basis.
177      * Equivalent to {@code newBuilder(from, false)}.
178      *
179      * @param from the {@code IssueManagement} instance to use as a basis
180      * @return a new {@code Builder}
181      */
182     @Nonnull
183     public static Builder newBuilder(IssueManagement from) {
184         return newBuilder(from, false);
185     }
186 
187     /**
188      * Creates a new {@code IssueManagement} builder instance using the specified object as a basis.
189      *
190      * @param from the {@code IssueManagement} instance to use as a basis
191      * @param forceCopy the boolean indicating if a copy should be forced
192      * @return a new {@code Builder}
193      */
194     @Nonnull
195     public static Builder newBuilder(IssueManagement from, boolean forceCopy) {
196         return new Builder(from, forceCopy);
197     }
198 
199     /**
200      * Builder class used to create IssueManagement instances.
201      * @see #with()
202      * @see #newBuilder()
203      */
204     @NotThreadSafe
205     public static class Builder
206     {
207         IssueManagement base;
208         String system;
209         String url;
210         Map<Object, InputLocation> locations;
211         InputLocation importedFrom;
212 
213         protected Builder(boolean withDefaults) {
214             if (withDefaults) {
215             }
216         }
217 
218         protected Builder(IssueManagement base, boolean forceCopy) {
219             if (forceCopy) {
220                 this.system = base.system;
221                 this.url = base.url;
222                 this.locations = base.locations;
223                 this.importedFrom = base.importedFrom;
224             } else {
225                 this.base = base;
226             }
227         }
228 
229         @Nonnull
230         public Builder system(String system) {
231             this.system = system;
232             return this;
233         }
234 
235         @Nonnull
236         public Builder url(String url) {
237             this.url = url;
238             return this;
239         }
240 
241 
242         @Nonnull
243         public Builder location(Object key, InputLocation location) {
244             if (location != null) {
245                 if (!(this.locations instanceof HashMap)) {
246                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
247                 }
248                 this.locations.put(key, location);
249             }
250             return this;
251         }
252 
253         @Nonnull
254         public Builder importedFrom(InputLocation importedFrom) {
255             this.importedFrom = importedFrom;
256             return this;
257         }
258 
259         @Nonnull
260         public IssueManagement build() {
261             // this method should not contain any logic other than creating (or reusing) an object in order to ease subclassing
262             if (base != null
263                     && (system == null || system == base.system)
264                     && (url == null || url == base.url)
265             ) {
266                 return base;
267             }
268             return new IssueManagement(this);
269         }
270     }
271 
272 
273             
274     /**
275      * @see java.lang.Object#toString()
276      */
277     public String toString()
278     {
279         return "IssueManagement {system=" + getSystem() + ", url=" + getUrl() + "}";
280     }
281             
282           
283 }