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