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