View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //   Generated by Maven, any modifications will be overwritten.
3   // ==============================================================
4   package org.apache.maven.plugin.lifecycle;
5   
6   import java.io.Serializable;
7   import java.util.ArrayList;
8   import java.util.Collection;
9   import java.util.Collections;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
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  import org.apache.maven.api.xml.Dom;
19  
20  /**
21   * A set of goals to execute.
22   */
23  @Generated @ThreadSafe @Immutable
24  public class Execution
25      implements Serializable
26  {
27      /**
28       * Configuration to pass to the goals.
29       */
30      final Dom configuration;
31      /**
32       * The goals to execute.
33       */
34      final List<String> goals;
35  
36      /**
37        * Constructor for this class, package protected.
38        * @see Builder#build()
39        */
40      Execution(
41          Dom configuration,
42          Collection<String> goals
43      )
44      {
45          this.configuration = configuration;
46          this.goals = ImmutableCollections.copy( goals );
47      }
48  
49      /**
50       * Configuration to pass to the goals.
51       */
52      public Dom getConfiguration()
53      {
54          return this.configuration;
55      }
56  
57      /**
58       * The goals to execute.
59       */
60      @Nonnull
61      public List<String> getGoals()
62      {
63          return this.goals;
64      }
65  
66      /**
67       * Creates a new builder with this object as the basis.
68       */
69      @Nonnull
70      public Builder with()
71      {
72          return newBuilder( this );
73      }
74      /** Creates a new Execution instance using the specified configuration. */
75      @Nonnull
76      public Execution withConfiguration( Dom configuration )
77      {
78          return with().configuration( configuration ).build();
79      }
80      /** Creates a new Execution instance using the specified goals. */
81      @Nonnull
82      public Execution withGoals( Collection<String> goals )
83      {
84          return with().goals( goals ).build();
85      }
86  
87      /**
88       * Creates a new Execution instance.
89       * Equivalent to {@code newInstance( true )}.
90       * @see #newInstance(boolean)
91       */
92      @Nonnull
93      public static Execution newInstance()
94      {
95          return newInstance( true );
96      }
97  
98      /**
99       * Creates a new Execution instance using default values or not.
100      * Equivalent to {@code newBuilder( withDefaults ).build()}.
101      */
102     @Nonnull
103     public static Execution newInstance( boolean withDefaults )
104     {
105         return newBuilder( withDefaults ).build();
106     }
107 
108     /**
109      * Creates a new Execution builder instance.
110      * Equivalent to {@code newBuilder( true )}.
111      * @see #newBuilder(boolean)
112      */
113     @Nonnull
114     public static Builder newBuilder()
115     {
116         return newBuilder( true );
117     }
118 
119     /**
120      * Creates a new Execution builder instance using default values or not.
121      */
122     @Nonnull
123     public static Builder newBuilder( boolean withDefaults )
124     {
125         return new Builder( withDefaults );
126     }
127 
128     /**
129      * Creates a new Execution builder instance using the specified object as a basis.
130      * Equivalent to {@code newBuilder( from, false )}.
131      */
132     @Nonnull
133     public static Builder newBuilder( Execution from )
134     {
135         return newBuilder( from, false );
136     }
137 
138     /**
139      * Creates a new Execution builder instance using the specified object as a basis.
140      */
141     @Nonnull
142     public static Builder newBuilder( Execution from, boolean forceCopy )
143     {
144         return new Builder( from, forceCopy );
145     }
146 
147     /**
148      * Builder class used to create Execution instances.
149      * @see #with()
150      * @see #newBuilder()
151      */
152     @NotThreadSafe
153     public static class Builder
154     {
155         Execution base;
156         Dom configuration;
157         Collection<String> goals;
158 
159         Builder( boolean withDefaults )
160         {
161             if ( withDefaults )
162             {
163             }
164         }
165 
166         Builder( Execution base, boolean forceCopy )
167         {
168             if ( forceCopy )
169             {
170                 this.configuration = base.configuration;
171                 this.goals = base.goals;
172             }
173             else
174             {
175                 this.base = base;
176             }
177         }
178 
179         @Nonnull
180         public Builder configuration( Dom configuration )
181         {
182             this.configuration = configuration;
183             return this;
184         }
185 
186         @Nonnull
187         public Builder goals( Collection<String> goals )
188         {
189             this.goals = goals;
190             return this;
191         }
192 
193 
194         @Nonnull
195         public Execution build()
196         {
197             if ( base != null
198                     && ( configuration == null || configuration == base.configuration )
199                     && ( goals == null || goals == base.goals )
200             )
201             {
202                 return base;
203             }
204             return new Execution(
205                 configuration != null ? configuration : ( base != null ? base.configuration : null ),
206                 goals != null ? goals : ( base != null ? base.goals : null )
207             );
208         }
209     }
210 
211 }