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.Collections;
9 import java.util.HashMap;
10 import java.util.Map;
11 import org.apache.maven.api.annotations.Experimental;
12 import org.apache.maven.api.annotations.Generated;
13 import org.apache.maven.api.annotations.Immutable;
14 import org.apache.maven.api.annotations.Nonnull;
15 import org.apache.maven.api.annotations.NotThreadSafe;
16 import org.apache.maven.api.annotations.ThreadSafe;
17 import org.apache.maven.api.xml.XmlNode;
18
19 /**
20 * Definition of a toolchain instance.
21 */
22 @Experimental
23 @Generated @ThreadSafe @Immutable
24 public class ToolchainModel
25 extends TrackableBase
26 implements Serializable
27 {
28 /**
29 * Type of toolchain:<ul>
30 * <li><code>jdk</code> for
31 * <a href="https://maven.apache.org/plugins/maven-toolchains-plugin/toolchains/jdk.html">JDK Standard Toolchain</a>,</li>
32 * <li>other value for
33 * <a href="https://maven.apache.org/plugins/maven-toolchains-plugin/toolchains/custom.html">Custom Toolchain</a></li>
34 * </ul>
35 */
36 final String type;
37 /**
38 * <p>Toolchain identification information, which will be matched against project requirements.</p>
39 * <p>For Maven 2.0.9 to 3.2.3, the actual content structure was completely open: each toolchain type would define its own format and semantics.
40 * In general, this was a properties format.</p>
41 * <p>Since Maven 3.2.4, the type for this field has been changed to Properties to match the de-facto format.</p>
42 * <p>Each toolchain defines its own properties names and semantics.</p>
43 */
44 final Map<String, String> provides;
45 /**
46 * <p>Toolchain configuration information, like location or any information that is to be retrieved.</p>
47 * <p>Actual content structure is completely open: each toolchain type will define its own format and semantics.</p>
48 * <p>In general, this is a properties format: <code><name>value</name></code> with
49 * per-toolchain defined properties names.</p>
50 */
51 final XmlNode configuration;
52
53 /**
54 * Constructor for this class, package protected.
55 * @see Builder#build()
56 */
57 ToolchainModel(
58 String type,
59 Map<String, String> provides,
60 XmlNode configuration
61 )
62 {
63 super(
64 );
65 this.type = type;
66 this.provides = ImmutableCollections.copy( provides );
67 this.configuration = configuration;
68 }
69
70 /**
71 * Type of toolchain:<ul>
72 * <li><code>jdk</code> for
73 * <a href="https://maven.apache.org/plugins/maven-toolchains-plugin/toolchains/jdk.html">JDK Standard Toolchain</a>,</li>
74 * <li>other value for
75 * <a href="https://maven.apache.org/plugins/maven-toolchains-plugin/toolchains/custom.html">Custom Toolchain</a></li>
76 * </ul>
77 *
78 * @return a {@code String}
79 */
80 public String getType()
81 {
82 return this.type;
83 }
84
85 /**
86 * <p>Toolchain identification information, which will be matched against project requirements.</p>
87 * <p>For Maven 2.0.9 to 3.2.3, the actual content structure was completely open: each toolchain type would define its own format and semantics.
88 * In general, this was a properties format.</p>
89 * <p>Since Maven 3.2.4, the type for this field has been changed to Properties to match the de-facto format.</p>
90 * <p>Each toolchain defines its own properties names and semantics.</p>
91 *
92 * @return a {@code Map<String, String>}
93 */
94 @Nonnull
95 public Map<String, String> getProvides()
96 {
97 return this.provides;
98 }
99
100 /**
101 * <p>Toolchain configuration information, like location or any information that is to be retrieved.</p>
102 * <p>Actual content structure is completely open: each toolchain type will define its own format and semantics.</p>
103 * <p>In general, this is a properties format: <code><name>value</name></code> with
104 * per-toolchain defined properties names.</p>
105 *
106 * @return a {@code XmlNode}
107 */
108 public XmlNode getConfiguration()
109 {
110 return this.configuration;
111 }
112
113 /**
114 * Creates a new builder with this object as the basis.
115 *
116 * @return a {@code Builder}
117 */
118 @Nonnull
119 public Builder with()
120 {
121 return newBuilder( this );
122 }
123 /**
124 * Creates a new {@code ToolchainModel} instance using the specified type.
125 *
126 * @param type the new {@code String} to use
127 * @return a {@code ToolchainModel} with the specified type
128 */
129 @Nonnull
130 public ToolchainModel withType( String type )
131 {
132 return with().type( type ).build();
133 }
134 /**
135 * Creates a new {@code ToolchainModel} instance using the specified provides.
136 *
137 * @param provides the new {@code Map<String, String>} to use
138 * @return a {@code ToolchainModel} with the specified provides
139 */
140 @Nonnull
141 public ToolchainModel withProvides( Map<String, String> provides )
142 {
143 return with().provides( provides ).build();
144 }
145 /**
146 * Creates a new {@code ToolchainModel} instance using the specified configuration.
147 *
148 * @param configuration the new {@code XmlNode} to use
149 * @return a {@code ToolchainModel} with the specified configuration
150 */
151 @Nonnull
152 public ToolchainModel withConfiguration( XmlNode configuration )
153 {
154 return with().configuration( configuration ).build();
155 }
156
157 /**
158 * Creates a new {@code ToolchainModel} instance.
159 * Equivalent to {@code newInstance( true )}.
160 * @see #newInstance(boolean)
161 *
162 * @return a new {@code ToolchainModel}
163 */
164 @Nonnull
165 public static ToolchainModel newInstance()
166 {
167 return newInstance( true );
168 }
169
170 /**
171 * Creates a new {@code ToolchainModel} instance using default values or not.
172 * Equivalent to {@code newBuilder( withDefaults ).build()}.
173 *
174 * @param withDefaults the boolean indicating whether default values should be used
175 * @return a new {@code ToolchainModel}
176 */
177 @Nonnull
178 public static ToolchainModel newInstance( boolean withDefaults )
179 {
180 return newBuilder( withDefaults ).build();
181 }
182
183 /**
184 * Creates a new {@code ToolchainModel} builder instance.
185 * Equivalent to {@code newBuilder( true )}.
186 * @see #newBuilder(boolean)
187 *
188 * @return a new {@code Builder}
189 */
190 @Nonnull
191 public static Builder newBuilder()
192 {
193 return newBuilder( true );
194 }
195
196 /**
197 * Creates a new {@code ToolchainModel} builder instance using default values or not.
198 *
199 * @param withDefaults the boolean indicating whether default values should be used
200 * @return a new {@code Builder}
201 */
202 @Nonnull
203 public static Builder newBuilder( boolean withDefaults )
204 {
205 return new Builder( withDefaults );
206 }
207
208 /**
209 * Creates a new {@code ToolchainModel} builder instance using the specified object as a basis.
210 * Equivalent to {@code newBuilder( from, false )}.
211 *
212 * @param from the {@code ToolchainModel} instance to use as a basis
213 * @return a new {@code Builder}
214 */
215 @Nonnull
216 public static Builder newBuilder( ToolchainModel from )
217 {
218 return newBuilder( from, false );
219 }
220
221 /**
222 * Creates a new {@code ToolchainModel} builder instance using the specified object as a basis.
223 *
224 * @param from the {@code ToolchainModel} instance to use as a basis
225 * @param forceCopy the boolean indicating if a copy should be forced
226 * @return a new {@code Builder}
227 */
228 @Nonnull
229 public static Builder newBuilder( ToolchainModel from, boolean forceCopy )
230 {
231 return new Builder( from, forceCopy );
232 }
233
234 /**
235 * Builder class used to create ToolchainModel instances.
236 * @see #with()
237 * @see #newBuilder()
238 */
239 @NotThreadSafe
240 public static class Builder
241 extends TrackableBase.Builder
242 {
243 ToolchainModel base;
244 String type;
245 Map<String, String> provides;
246 XmlNode configuration;
247
248 Builder( boolean withDefaults )
249 {
250 super( withDefaults );
251 if ( withDefaults )
252 {
253 }
254 }
255
256 Builder( ToolchainModel base, boolean forceCopy )
257 {
258 super( base, forceCopy );
259 if ( forceCopy )
260 {
261 this.type = base.type;
262 this.provides = base.provides;
263 this.configuration = base.configuration;
264 }
265 else
266 {
267 this.base = base;
268 }
269 }
270
271 @Nonnull
272 public Builder type( String type )
273 {
274 this.type = type;
275 return this;
276 }
277
278 @Nonnull
279 public Builder provides( Map<String, String> provides )
280 {
281 this.provides = provides;
282 return this;
283 }
284
285 @Nonnull
286 public Builder configuration( XmlNode configuration )
287 {
288 this.configuration = configuration;
289 return this;
290 }
291
292
293 @Nonnull
294 public ToolchainModel build()
295 {
296 if ( base != null
297 && ( type == null || type == base.type )
298 && ( provides == null || provides == base.provides )
299 && ( configuration == null || configuration == base.configuration )
300 )
301 {
302 return base;
303 }
304 return new ToolchainModel(
305 type != null ? type : ( base != null ? base.type : null ),
306 provides != null ? provides : ( base != null ? base.provides : null ),
307 configuration != null ? configuration : ( base != null ? base.configuration : null )
308 );
309 }
310 }
311
312
313
314 /**
315 * Method hashCode.
316 *
317 * @return int
318 */
319 public int hashCode()
320 {
321 int result = 17;
322
323 result = 37 * result + ( getType() != null ? getType().hashCode() : 0 );
324 result = 37 * result + ( getProvides() != null ? getProvides().hashCode() : 0 );
325
326 return result;
327 } //-- int hashCode()
328
329 /**
330 * Method equals.
331 *
332 * @param other
333 * @return boolean
334 */
335 public boolean equals( Object other )
336 {
337 if ( this == other )
338 {
339 return true;
340 }
341
342 if ( !( other instanceof ToolchainModel ) )
343 {
344 return false;
345 }
346
347 ToolchainModel that = (ToolchainModel) other;
348 boolean result = true;
349
350 result = result && ( getType() == null ? that.getType() == null : getType().equals( that.getType() ) );
351 result = result && ( getProvides() == null ? that.getProvides() == null : getProvides().equals( that.getProvides() ) );
352
353 return result;
354 } //-- boolean equals( Object )
355
356
357 }