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