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.plugin.descriptor;
6   
7   import java.io.Serializable;
8   import java.util.ArrayList;
9   import java.util.Collection;
10  import java.util.Collections;
11  import java.util.HashMap;
12  import java.util.List;
13  import java.util.Map;
14  import org.apache.maven.api.annotations.Experimental;
15  import org.apache.maven.api.annotations.Generated;
16  import org.apache.maven.api.annotations.Immutable;
17  import org.apache.maven.api.annotations.Nonnull;
18  import org.apache.maven.api.annotations.NotThreadSafe;
19  import org.apache.maven.api.annotations.ThreadSafe;
20  
21  /**
22   * Root element of the <code>plugin.xml</code> file.
23   */
24  @Experimental
25  @Generated @ThreadSafe @Immutable
26  public class PluginDescriptor
27      implements Serializable
28  {
29      final String namespaceUri;
30      final String modelEncoding;
31      /**
32       * Name of the plugin.
33       */
34      final String name;
35      /**
36       * Description of the plugin.
37       */
38      final String description;
39      /**
40       * The group id of the plugin.
41       */
42      final String groupId;
43      /**
44       * The artifact id of the plugin.
45       */
46      final String artifactId;
47      /**
48       * The version of the plugin.
49       */
50      final String version;
51      /**
52       * 
53       */
54      final String goalPrefix;
55      /**
56       * 
57       */
58      final boolean isolatedRealm;
59      /**
60       * 
61       */
62      final boolean inheritedByDefault;
63      /**
64       * A version range which specifies the supported Java versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required.
65       */
66      final String requiredJavaVersion;
67      /**
68       * A version range which specifies the supported Maven versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required. This value takes precedence over the POMs Maven prerequisite.
69       */
70      final String requiredMavenVersion;
71      /**
72       * Description of each Mojo provided by the plugin.
73       */
74      final List<MojoDescriptor> mojos;
75  
76      /**
77        * Constructor for this class, package protected.
78        * @see Builder#build()
79        */
80      PluginDescriptor(
81          String namespaceUri,
82          String modelEncoding,
83          String name,
84          String description,
85          String groupId,
86          String artifactId,
87          String version,
88          String goalPrefix,
89          boolean isolatedRealm,
90          boolean inheritedByDefault,
91          String requiredJavaVersion,
92          String requiredMavenVersion,
93          Collection<MojoDescriptor> mojos
94      ) {
95          this.namespaceUri = namespaceUri;
96          this.modelEncoding = modelEncoding;
97          this.name = name;
98          this.description = description;
99          this.groupId = groupId;
100         this.artifactId = artifactId;
101         this.version = version;
102         this.goalPrefix = goalPrefix;
103         this.isolatedRealm = isolatedRealm;
104         this.inheritedByDefault = inheritedByDefault;
105         this.requiredJavaVersion = requiredJavaVersion;
106         this.requiredMavenVersion = requiredMavenVersion;
107         this.mojos = ImmutableCollections.copy(mojos);
108     }
109 
110     public String getNamespaceUri() {
111         return namespaceUri;
112     }
113 
114     public String getModelEncoding() {
115         return modelEncoding;
116     }
117 
118     /**
119      * Name of the plugin.
120      *
121      * @return a {@code String}
122      */
123     public String getName() {
124         return this.name;
125     }
126 
127     /**
128      * Description of the plugin.
129      *
130      * @return a {@code String}
131      */
132     public String getDescription() {
133         return this.description;
134     }
135 
136     /**
137      * The group id of the plugin.
138      *
139      * @return a {@code String}
140      */
141     public String getGroupId() {
142         return this.groupId;
143     }
144 
145     /**
146      * The artifact id of the plugin.
147      *
148      * @return a {@code String}
149      */
150     public String getArtifactId() {
151         return this.artifactId;
152     }
153 
154     /**
155      * The version of the plugin.
156      *
157      * @return a {@code String}
158      */
159     public String getVersion() {
160         return this.version;
161     }
162 
163     /**
164      * 
165      *
166      * @return a {@code String}
167      */
168     public String getGoalPrefix() {
169         return this.goalPrefix;
170     }
171 
172     /**
173      * 
174      *
175      * @return a {@code boolean}
176      */
177     public boolean isIsolatedRealm() {
178         return this.isolatedRealm;
179     }
180 
181     /**
182      * 
183      *
184      * @return a {@code boolean}
185      */
186     public boolean isInheritedByDefault() {
187         return this.inheritedByDefault;
188     }
189 
190     /**
191      * A version range which specifies the supported Java versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required.
192      *
193      * @return a {@code String}
194      */
195     public String getRequiredJavaVersion() {
196         return this.requiredJavaVersion;
197     }
198 
199     /**
200      * A version range which specifies the supported Maven versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required. This value takes precedence over the POMs Maven prerequisite.
201      *
202      * @return a {@code String}
203      */
204     public String getRequiredMavenVersion() {
205         return this.requiredMavenVersion;
206     }
207 
208     /**
209      * Description of each Mojo provided by the plugin.
210      *
211      * @return a {@code List<MojoDescriptor>}
212      */
213     @Nonnull
214     public List<MojoDescriptor> getMojos() {
215         return this.mojos;
216     }
217 
218     /**
219      * Creates a new builder with this object as the basis.
220      *
221      * @return a {@code Builder}
222      */
223     @Nonnull
224     public Builder with() {
225         return newBuilder(this);
226     }
227     /**
228      * Creates a new {@code PluginDescriptor} instance using the specified name.
229      *
230      * @param name the new {@code String} to use
231      * @return a {@code PluginDescriptor} with the specified name
232      */
233     @Nonnull
234     public PluginDescriptor withName(String name) {
235         return newBuilder(this, true).name(name).build();
236     }
237     /**
238      * Creates a new {@code PluginDescriptor} instance using the specified description.
239      *
240      * @param description the new {@code String} to use
241      * @return a {@code PluginDescriptor} with the specified description
242      */
243     @Nonnull
244     public PluginDescriptor withDescription(String description) {
245         return newBuilder(this, true).description(description).build();
246     }
247     /**
248      * Creates a new {@code PluginDescriptor} instance using the specified groupId.
249      *
250      * @param groupId the new {@code String} to use
251      * @return a {@code PluginDescriptor} with the specified groupId
252      */
253     @Nonnull
254     public PluginDescriptor withGroupId(String groupId) {
255         return newBuilder(this, true).groupId(groupId).build();
256     }
257     /**
258      * Creates a new {@code PluginDescriptor} instance using the specified artifactId.
259      *
260      * @param artifactId the new {@code String} to use
261      * @return a {@code PluginDescriptor} with the specified artifactId
262      */
263     @Nonnull
264     public PluginDescriptor withArtifactId(String artifactId) {
265         return newBuilder(this, true).artifactId(artifactId).build();
266     }
267     /**
268      * Creates a new {@code PluginDescriptor} instance using the specified version.
269      *
270      * @param version the new {@code String} to use
271      * @return a {@code PluginDescriptor} with the specified version
272      */
273     @Nonnull
274     public PluginDescriptor withVersion(String version) {
275         return newBuilder(this, true).version(version).build();
276     }
277     /**
278      * Creates a new {@code PluginDescriptor} instance using the specified goalPrefix.
279      *
280      * @param goalPrefix the new {@code String} to use
281      * @return a {@code PluginDescriptor} with the specified goalPrefix
282      */
283     @Nonnull
284     public PluginDescriptor withGoalPrefix(String goalPrefix) {
285         return newBuilder(this, true).goalPrefix(goalPrefix).build();
286     }
287     /**
288      * Creates a new {@code PluginDescriptor} instance using the specified isolatedRealm.
289      *
290      * @param isolatedRealm the new {@code boolean} to use
291      * @return a {@code PluginDescriptor} with the specified isolatedRealm
292      */
293     @Nonnull
294     public PluginDescriptor withIsolatedRealm(boolean isolatedRealm) {
295         return newBuilder(this, true).isolatedRealm(isolatedRealm).build();
296     }
297     /**
298      * Creates a new {@code PluginDescriptor} instance using the specified inheritedByDefault.
299      *
300      * @param inheritedByDefault the new {@code boolean} to use
301      * @return a {@code PluginDescriptor} with the specified inheritedByDefault
302      */
303     @Nonnull
304     public PluginDescriptor withInheritedByDefault(boolean inheritedByDefault) {
305         return newBuilder(this, true).inheritedByDefault(inheritedByDefault).build();
306     }
307     /**
308      * Creates a new {@code PluginDescriptor} instance using the specified requiredJavaVersion.
309      *
310      * @param requiredJavaVersion the new {@code String} to use
311      * @return a {@code PluginDescriptor} with the specified requiredJavaVersion
312      */
313     @Nonnull
314     public PluginDescriptor withRequiredJavaVersion(String requiredJavaVersion) {
315         return newBuilder(this, true).requiredJavaVersion(requiredJavaVersion).build();
316     }
317     /**
318      * Creates a new {@code PluginDescriptor} instance using the specified requiredMavenVersion.
319      *
320      * @param requiredMavenVersion the new {@code String} to use
321      * @return a {@code PluginDescriptor} with the specified requiredMavenVersion
322      */
323     @Nonnull
324     public PluginDescriptor withRequiredMavenVersion(String requiredMavenVersion) {
325         return newBuilder(this, true).requiredMavenVersion(requiredMavenVersion).build();
326     }
327     /**
328      * Creates a new {@code PluginDescriptor} instance using the specified mojos.
329      *
330      * @param mojos the new {@code Collection<MojoDescriptor>} to use
331      * @return a {@code PluginDescriptor} with the specified mojos
332      */
333     @Nonnull
334     public PluginDescriptor withMojos(Collection<MojoDescriptor> mojos) {
335         return newBuilder(this, true).mojos(mojos).build();
336     }
337 
338     /**
339      * Creates a new {@code PluginDescriptor} instance.
340      * Equivalent to {@code newInstance(true)}.
341      * @see #newInstance(boolean)
342      *
343      * @return a new {@code PluginDescriptor}
344      */
345     @Nonnull
346     public static PluginDescriptor newInstance() {
347         return newInstance(true);
348     }
349 
350     /**
351      * Creates a new {@code PluginDescriptor} instance using default values or not.
352      * Equivalent to {@code newBuilder(withDefaults).build()}.
353      *
354      * @param withDefaults the boolean indicating whether default values should be used
355      * @return a new {@code PluginDescriptor}
356      */
357     @Nonnull
358     public static PluginDescriptor newInstance(boolean withDefaults) {
359         return newBuilder(withDefaults).build();
360     }
361 
362     /**
363      * Creates a new {@code PluginDescriptor} builder instance.
364      * Equivalent to {@code newBuilder(true)}.
365      * @see #newBuilder(boolean)
366      *
367      * @return a new {@code Builder}
368      */
369     @Nonnull
370     public static Builder newBuilder() {
371         return newBuilder(true);
372     }
373 
374     /**
375      * Creates a new {@code PluginDescriptor} builder instance using default values or not.
376      *
377      * @param withDefaults the boolean indicating whether default values should be used
378      * @return a new {@code Builder}
379      */
380     @Nonnull
381     public static Builder newBuilder(boolean withDefaults) {
382         return new Builder(withDefaults);
383     }
384 
385     /**
386      * Creates a new {@code PluginDescriptor} builder instance using the specified object as a basis.
387      * Equivalent to {@code newBuilder(from, false)}.
388      *
389      * @param from the {@code PluginDescriptor} instance to use as a basis
390      * @return a new {@code Builder}
391      */
392     @Nonnull
393     public static Builder newBuilder(PluginDescriptor from) {
394         return newBuilder(from, false);
395     }
396 
397     /**
398      * Creates a new {@code PluginDescriptor} builder instance using the specified object as a basis.
399      *
400      * @param from the {@code PluginDescriptor} instance to use as a basis
401      * @param forceCopy the boolean indicating if a copy should be forced
402      * @return a new {@code Builder}
403      */
404     @Nonnull
405     public static Builder newBuilder(PluginDescriptor from, boolean forceCopy) {
406         return new Builder(from, forceCopy);
407     }
408 
409     /**
410      * Builder class used to create PluginDescriptor instances.
411      * @see #with()
412      * @see #newBuilder()
413      */
414     @NotThreadSafe
415     public static class Builder
416     {
417         PluginDescriptor base;
418         String namespaceUri;
419         String modelEncoding;
420         String name;
421         String description;
422         String groupId;
423         String artifactId;
424         String version;
425         String goalPrefix;
426         Boolean isolatedRealm;
427         Boolean inheritedByDefault;
428         String requiredJavaVersion;
429         String requiredMavenVersion;
430         Collection<MojoDescriptor> mojos;
431 
432         Builder(boolean withDefaults) {
433             if (withDefaults) {
434                 this.isolatedRealm = false;
435                 this.inheritedByDefault = true;
436             }
437         }
438 
439         Builder(PluginDescriptor base, boolean forceCopy) {
440             this.namespaceUri = base.namespaceUri;
441             this.modelEncoding = base.modelEncoding;
442             if (forceCopy) {
443                 this.name = base.name;
444                 this.description = base.description;
445                 this.groupId = base.groupId;
446                 this.artifactId = base.artifactId;
447                 this.version = base.version;
448                 this.goalPrefix = base.goalPrefix;
449                 this.isolatedRealm = base.isolatedRealm;
450                 this.inheritedByDefault = base.inheritedByDefault;
451                 this.requiredJavaVersion = base.requiredJavaVersion;
452                 this.requiredMavenVersion = base.requiredMavenVersion;
453                 this.mojos = base.mojos;
454             } else {
455                 this.base = base;
456             }
457         }
458 
459         @Nonnull
460         public Builder namespaceUri(String namespaceUri) {
461             this.namespaceUri = namespaceUri;
462             return this;
463         }
464 
465         @Nonnull
466         public Builder modelEncoding(String modelEncoding) {
467             this.modelEncoding = modelEncoding;
468             return this;
469         }
470 
471         @Nonnull
472         public Builder name(String name) {
473             this.name = name;
474             return this;
475         }
476 
477         @Nonnull
478         public Builder description(String description) {
479             this.description = description;
480             return this;
481         }
482 
483         @Nonnull
484         public Builder groupId(String groupId) {
485             this.groupId = groupId;
486             return this;
487         }
488 
489         @Nonnull
490         public Builder artifactId(String artifactId) {
491             this.artifactId = artifactId;
492             return this;
493         }
494 
495         @Nonnull
496         public Builder version(String version) {
497             this.version = version;
498             return this;
499         }
500 
501         @Nonnull
502         public Builder goalPrefix(String goalPrefix) {
503             this.goalPrefix = goalPrefix;
504             return this;
505         }
506 
507         @Nonnull
508         public Builder isolatedRealm(boolean isolatedRealm) {
509             this.isolatedRealm = isolatedRealm;
510             return this;
511         }
512 
513         @Nonnull
514         public Builder inheritedByDefault(boolean inheritedByDefault) {
515             this.inheritedByDefault = inheritedByDefault;
516             return this;
517         }
518 
519         @Nonnull
520         public Builder requiredJavaVersion(String requiredJavaVersion) {
521             this.requiredJavaVersion = requiredJavaVersion;
522             return this;
523         }
524 
525         @Nonnull
526         public Builder requiredMavenVersion(String requiredMavenVersion) {
527             this.requiredMavenVersion = requiredMavenVersion;
528             return this;
529         }
530 
531         @Nonnull
532         public Builder mojos(Collection<MojoDescriptor> mojos) {
533             this.mojos = mojos;
534             return this;
535         }
536 
537 
538         @Nonnull
539         public PluginDescriptor build() {
540             if (base != null
541                     && (name == null || name == base.name)
542                     && (description == null || description == base.description)
543                     && (groupId == null || groupId == base.groupId)
544                     && (artifactId == null || artifactId == base.artifactId)
545                     && (version == null || version == base.version)
546                     && (goalPrefix == null || goalPrefix == base.goalPrefix)
547                     && (isolatedRealm == null || isolatedRealm == base.isolatedRealm)
548                     && (inheritedByDefault == null || inheritedByDefault == base.inheritedByDefault)
549                     && (requiredJavaVersion == null || requiredJavaVersion == base.requiredJavaVersion)
550                     && (requiredMavenVersion == null || requiredMavenVersion == base.requiredMavenVersion)
551                     && (mojos == null || mojos == base.mojos)
552             ) {
553                 return base;
554             }
555             return new PluginDescriptor(
556                 namespaceUri != null ? namespaceUri : (base != null ? base.namespaceUri : ""),
557                 modelEncoding != null ? modelEncoding : (base != null ? base.modelEncoding : "UTF-8"),
558                 name != null ? name : (base != null ? base.name : null),
559                 description != null ? description : (base != null ? base.description : null),
560                 groupId != null ? groupId : (base != null ? base.groupId : null),
561                 artifactId != null ? artifactId : (base != null ? base.artifactId : null),
562                 version != null ? version : (base != null ? base.version : null),
563                 goalPrefix != null ? goalPrefix : (base != null ? base.goalPrefix : null),
564                 isolatedRealm != null ? isolatedRealm : (base != null ? base.isolatedRealm : false),
565                 inheritedByDefault != null ? inheritedByDefault : (base != null ? base.inheritedByDefault : true),
566                 requiredJavaVersion != null ? requiredJavaVersion : (base != null ? base.requiredJavaVersion : null),
567                 requiredMavenVersion != null ? requiredMavenVersion : (base != null ? base.requiredMavenVersion : null),
568                 mojos != null ? mojos : (base != null ? base.mojos : null)
569             );
570         }
571     }
572 
573 
574     public String getPluginLookupKey() {
575         return groupId + ":" + artifactId;
576     }
577 
578     public String getId() {
579         return groupId + ":" + artifactId + ":" + version;
580     }
581 
582           
583 }