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 org.apache.maven.api.annotations.Experimental;
12  import org.apache.maven.api.annotations.Generated;
13  import org.apache.maven.api.annotations.Immutable;
14  import org.apache.maven.api.annotations.Nonnull;
15  import org.apache.maven.api.annotations.NotThreadSafe;
16  import org.apache.maven.api.annotations.ThreadSafe;
17  
18  /**
19   * Information about the issue tracking (or bug tracking) system used to manage this
20   * project.
21   */
22  @Experimental
23  @Generated @ThreadSafe @Immutable
24  public class IssueManagement
25      implements Serializable, InputLocationTracker
26  {
27      /**
28       * The name of the issue management system, e.g. Bugzilla
29       */
30      final String system;
31      /**
32       * URL for the issue management system used by the project.
33       */
34      final String url;
35      /** Location of the xml element for this object. */
36      final InputLocation location;
37      /** Location of the xml element for the field system. */
38      final InputLocation systemLocation;
39      /** Location of the xml element for the field url. */
40      final InputLocation urlLocation;
41      /** Other locations */
42      final Map<Object, InputLocation> locations;
43  
44      /**
45        * Constructor for this class, package protected.
46        * @see Builder#build()
47        */
48      IssueManagement(
49          String system,
50          String url,
51          Map<Object, InputLocation> locations,
52          InputLocation location,
53          InputLocation systemLocation,
54          InputLocation urlLocation
55      )
56      {
57          this.system = system;
58          this.url = url;
59          this.locations = ImmutableCollections.copy( locations );
60          this.location = location;
61          this.systemLocation = systemLocation;
62          this.urlLocation = urlLocation;
63      }
64  
65      /**
66       * The name of the issue management system, e.g. Bugzilla
67       *
68       * @return a {@code String}
69       */
70      public String getSystem()
71      {
72          return this.system;
73      }
74  
75      /**
76       * URL for the issue management system used by the project.
77       *
78       * @return a {@code String}
79       */
80      public String getUrl()
81      {
82          return this.url;
83      }
84  
85      /**
86       * Gets the location of the specified field in the input source.
87       */
88      public InputLocation getLocation( Object key )
89      {
90          if ( key instanceof String )
91          {
92              switch ( ( String ) key )
93              {
94                  case "":
95                      return location;
96                  case "system":
97                      return systemLocation;
98                  case "url":
99                      return urlLocation;
100             }
101         }
102         return locations != null ? locations.get( key ) : null;
103     }
104 
105     /**
106      * Creates a new builder with this object as the basis.
107      *
108      * @return a {@code Builder}
109      */
110     @Nonnull
111     public Builder with()
112     {
113         return newBuilder( this );
114     }
115     /**
116      * Creates a new {@code IssueManagement} instance using the specified system.
117      *
118      * @param system the new {@code String} to use
119      * @return a {@code IssueManagement} with the specified system
120      */
121     @Nonnull
122     public IssueManagement withSystem( String system )
123     {
124         return with().system( system ).build();
125     }
126     /**
127      * Creates a new {@code IssueManagement} instance using the specified url.
128      *
129      * @param url the new {@code String} to use
130      * @return a {@code IssueManagement} with the specified url
131      */
132     @Nonnull
133     public IssueManagement withUrl( String url )
134     {
135         return with().url( url ).build();
136     }
137 
138     /**
139      * Creates a new {@code IssueManagement} instance.
140      * Equivalent to {@code newInstance( true )}.
141      * @see #newInstance(boolean)
142      *
143      * @return a new {@code IssueManagement}
144      */
145     @Nonnull
146     public static IssueManagement newInstance()
147     {
148         return newInstance( true );
149     }
150 
151     /**
152      * Creates a new {@code IssueManagement} instance using default values or not.
153      * Equivalent to {@code newBuilder( withDefaults ).build()}.
154      *
155      * @param withDefaults the boolean indicating whether default values should be used
156      * @return a new {@code IssueManagement}
157      */
158     @Nonnull
159     public static IssueManagement newInstance( boolean withDefaults )
160     {
161         return newBuilder( withDefaults ).build();
162     }
163 
164     /**
165      * Creates a new {@code IssueManagement} builder instance.
166      * Equivalent to {@code newBuilder( true )}.
167      * @see #newBuilder(boolean)
168      *
169      * @return a new {@code Builder}
170      */
171     @Nonnull
172     public static Builder newBuilder()
173     {
174         return newBuilder( true );
175     }
176 
177     /**
178      * Creates a new {@code IssueManagement} builder instance using default values or not.
179      *
180      * @param withDefaults the boolean indicating whether default values should be used
181      * @return a new {@code Builder}
182      */
183     @Nonnull
184     public static Builder newBuilder( boolean withDefaults )
185     {
186         return new Builder( withDefaults );
187     }
188 
189     /**
190      * Creates a new {@code IssueManagement} builder instance using the specified object as a basis.
191      * Equivalent to {@code newBuilder( from, false )}.
192      *
193      * @param from the {@code IssueManagement} instance to use as a basis
194      * @return a new {@code Builder}
195      */
196     @Nonnull
197     public static Builder newBuilder( IssueManagement from )
198     {
199         return newBuilder( from, false );
200     }
201 
202     /**
203      * Creates a new {@code IssueManagement} builder instance using the specified object as a basis.
204      *
205      * @param from the {@code IssueManagement} instance to use as a basis
206      * @param forceCopy the boolean indicating if a copy should be forced
207      * @return a new {@code Builder}
208      */
209     @Nonnull
210     public static Builder newBuilder( IssueManagement from, boolean forceCopy )
211     {
212         return new Builder( from, forceCopy );
213     }
214 
215     /**
216      * Builder class used to create IssueManagement instances.
217      * @see #with()
218      * @see #newBuilder()
219      */
220     @NotThreadSafe
221     public static class Builder
222     {
223         IssueManagement base;
224         String system;
225         String url;
226         Map<Object, InputLocation> locations;
227 
228         Builder( boolean withDefaults )
229         {
230             if ( withDefaults )
231             {
232             }
233         }
234 
235         Builder( IssueManagement base, boolean forceCopy )
236         {
237             if ( forceCopy )
238             {
239                 this.system = base.system;
240                 this.url = base.url;
241             }
242             else
243             {
244                 this.base = base;
245             }
246         }
247 
248         @Nonnull
249         public Builder system( String system )
250         {
251             this.system = system;
252             return this;
253         }
254 
255         @Nonnull
256         public Builder url( String url )
257         {
258             this.url = url;
259             return this;
260         }
261 
262 
263         @Nonnull
264         public Builder location( Object key, InputLocation location )
265         {
266             if ( location != null )
267             {
268                 if ( this.locations == null )
269                 {
270                     this.locations = new HashMap<>();
271                 }
272                 this.locations.put( key, location );
273             }
274             return this;
275         }
276 
277         @Nonnull
278         public IssueManagement build()
279         {
280             if ( base != null
281                     && ( system == null || system == base.system )
282                     && ( url == null || url == base.url )
283             )
284             {
285                 return base;
286             }
287             Map<Object, InputLocation> locations = null;
288             InputLocation location = null;
289             InputLocation systemLocation = null;
290             InputLocation urlLocation = null;
291             if ( this.locations != null )
292             {
293                 locations = this.locations;
294                 location = locations.remove( "" );
295                 systemLocation = locations.remove( "system" );
296                 urlLocation = locations.remove( "url" );
297             }
298             return new IssueManagement(
299                 system != null ? system : ( base != null ? base.system : null ),
300                 url != null ? url : ( base != null ? base.url : null ),
301                 locations != null ? locations : ( base != null ? base.locations : null ),
302                 location != null ? location : ( base != null ? base.location : null ),
303                 systemLocation != null ? systemLocation : ( base != null ? base.systemLocation : null ),
304                 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null )
305             );
306         }
307     }
308 
309 
310             
311     /**
312      * @see java.lang.Object#toString()
313      */
314     public String toString()
315     {
316         return "IssueManagement {system=" + getSystem() + ", url=" + getUrl() + "}";
317     }
318             
319           
320 }