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