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.plugin.lifecycle;
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  import org.apache.maven.api.xml.XmlNode;
21  
22  /**
23   * A set of goals to execute.
24   */
25  @Experimental
26  @Generated @ThreadSafe @Immutable
27  public class Execution
28      implements Serializable
29  {
30      /**
31       * Configuration to pass to the goals.
32       */
33      final XmlNode configuration;
34      /**
35       * The goals to execute.
36       */
37      final List<String> goals;
38  
39      /**
40        * Constructor for this class, package protected.
41        * @see Builder#build()
42        */
43      Execution(
44          XmlNode configuration,
45          Collection<String> goals
46      )
47      {
48          this.configuration = configuration;
49          this.goals = ImmutableCollections.copy( goals );
50      }
51  
52      /**
53       * Configuration to pass to the goals.
54       *
55       * @return a {@code XmlNode}
56       */
57      public XmlNode getConfiguration()
58      {
59          return this.configuration;
60      }
61  
62      /**
63       * The goals to execute.
64       *
65       * @return a {@code List<String>}
66       */
67      @Nonnull
68      public List<String> getGoals()
69      {
70          return this.goals;
71      }
72  
73      /**
74       * Creates a new builder with this object as the basis.
75       *
76       * @return a {@code Builder}
77       */
78      @Nonnull
79      public Builder with()
80      {
81          return newBuilder( this );
82      }
83      /**
84       * Creates a new {@code Execution} instance using the specified configuration.
85       *
86       * @param configuration the new {@code XmlNode} to use
87       * @return a {@code Execution} with the specified configuration
88       */
89      @Nonnull
90      public Execution withConfiguration( XmlNode configuration )
91      {
92          return with().configuration( configuration ).build();
93      }
94      /**
95       * Creates a new {@code Execution} instance using the specified goals.
96       *
97       * @param goals the new {@code Collection<String>} to use
98       * @return a {@code Execution} with the specified goals
99       */
100     @Nonnull
101     public Execution withGoals( Collection<String> goals )
102     {
103         return with().goals( goals ).build();
104     }
105 
106     /**
107      * Creates a new {@code Execution} instance.
108      * Equivalent to {@code newInstance( true )}.
109      * @see #newInstance(boolean)
110      *
111      * @return a new {@code Execution}
112      */
113     @Nonnull
114     public static Execution newInstance()
115     {
116         return newInstance( true );
117     }
118 
119     /**
120      * Creates a new {@code Execution} instance using default values or not.
121      * Equivalent to {@code newBuilder( withDefaults ).build()}.
122      *
123      * @param withDefaults the boolean indicating whether default values should be used
124      * @return a new {@code Execution}
125      */
126     @Nonnull
127     public static Execution newInstance( boolean withDefaults )
128     {
129         return newBuilder( withDefaults ).build();
130     }
131 
132     /**
133      * Creates a new {@code Execution} builder instance.
134      * Equivalent to {@code newBuilder( true )}.
135      * @see #newBuilder(boolean)
136      *
137      * @return a new {@code Builder}
138      */
139     @Nonnull
140     public static Builder newBuilder()
141     {
142         return newBuilder( true );
143     }
144 
145     /**
146      * Creates a new {@code Execution} builder instance using default values or not.
147      *
148      * @param withDefaults the boolean indicating whether default values should be used
149      * @return a new {@code Builder}
150      */
151     @Nonnull
152     public static Builder newBuilder( boolean withDefaults )
153     {
154         return new Builder( withDefaults );
155     }
156 
157     /**
158      * Creates a new {@code Execution} builder instance using the specified object as a basis.
159      * Equivalent to {@code newBuilder( from, false )}.
160      *
161      * @param from the {@code Execution} instance to use as a basis
162      * @return a new {@code Builder}
163      */
164     @Nonnull
165     public static Builder newBuilder( Execution from )
166     {
167         return newBuilder( from, false );
168     }
169 
170     /**
171      * Creates a new {@code Execution} builder instance using the specified object as a basis.
172      *
173      * @param from the {@code Execution} instance to use as a basis
174      * @param forceCopy the boolean indicating if a copy should be forced
175      * @return a new {@code Builder}
176      */
177     @Nonnull
178     public static Builder newBuilder( Execution from, boolean forceCopy )
179     {
180         return new Builder( from, forceCopy );
181     }
182 
183     /**
184      * Builder class used to create Execution instances.
185      * @see #with()
186      * @see #newBuilder()
187      */
188     @NotThreadSafe
189     public static class Builder
190     {
191         Execution base;
192         XmlNode configuration;
193         Collection<String> goals;
194 
195         Builder( boolean withDefaults )
196         {
197             if ( withDefaults )
198             {
199             }
200         }
201 
202         Builder( Execution base, boolean forceCopy )
203         {
204             if ( forceCopy )
205             {
206                 this.configuration = base.configuration;
207                 this.goals = base.goals;
208             }
209             else
210             {
211                 this.base = base;
212             }
213         }
214 
215         @Nonnull
216         public Builder configuration( XmlNode configuration )
217         {
218             this.configuration = configuration;
219             return this;
220         }
221 
222         @Nonnull
223         public Builder goals( Collection<String> goals )
224         {
225             this.goals = goals;
226             return this;
227         }
228 
229 
230         @Nonnull
231         public Execution build()
232         {
233             if ( base != null
234                     && ( configuration == null || configuration == base.configuration )
235                     && ( goals == null || goals == base.goals )
236             )
237             {
238                 return base;
239             }
240             return new Execution(
241                 configuration != null ? configuration : ( base != null ? base.configuration : null ),
242                 goals != null ? goals : ( base != null ? base.goals : null )
243             );
244         }
245     }
246 
247 }