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