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 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 return this.type;
81 }
82
83 /**
84 * <p>Toolchain identification information, which will be matched against project requirements.</p>
85 * <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.
86 * In general, this was a properties format.</p>
87 * <p>Since Maven 3.2.4, the type for this field has been changed to Properties to match the de-facto format.</p>
88 * <p>Each toolchain defines its own properties names and semantics.</p>
89 *
90 * @return a {@code Map<String, String>}
91 */
92 @Nonnull
93 public Map<String, String> getProvides() {
94 return this.provides;
95 }
96
97 /**
98 * <p>Toolchain configuration information, like location or any information that is to be retrieved.</p>
99 * <p>Actual content structure is completely open: each toolchain type will define its own format and semantics.</p>
100 * <p>In general, this is a properties format: <code><name>value</name></code> with
101 * per-toolchain defined properties names.</p>
102 *
103 * @return a {@code XmlNode}
104 */
105 public XmlNode getConfiguration() {
106 return this.configuration;
107 }
108
109 /**
110 * Creates a new builder with this object as the basis.
111 *
112 * @return a {@code Builder}
113 */
114 @Nonnull
115 public Builder with() {
116 return newBuilder(this);
117 }
118 /**
119 * Creates a new {@code ToolchainModel} instance using the specified type.
120 *
121 * @param type the new {@code String} to use
122 * @return a {@code ToolchainModel} with the specified type
123 */
124 @Nonnull
125 public ToolchainModel withType(String type) {
126 return newBuilder(this, true).type(type).build();
127 }
128 /**
129 * Creates a new {@code ToolchainModel} instance using the specified provides.
130 *
131 * @param provides the new {@code Map<String, String>} to use
132 * @return a {@code ToolchainModel} with the specified provides
133 */
134 @Nonnull
135 public ToolchainModel withProvides(Map<String, String> provides) {
136 return newBuilder(this, true).provides(provides).build();
137 }
138 /**
139 * Creates a new {@code ToolchainModel} instance using the specified configuration.
140 *
141 * @param configuration the new {@code XmlNode} to use
142 * @return a {@code ToolchainModel} with the specified configuration
143 */
144 @Nonnull
145 public ToolchainModel withConfiguration(XmlNode configuration) {
146 return newBuilder(this, true).configuration(configuration).build();
147 }
148
149 /**
150 * Creates a new {@code ToolchainModel} instance.
151 * Equivalent to {@code newInstance(true)}.
152 * @see #newInstance(boolean)
153 *
154 * @return a new {@code ToolchainModel}
155 */
156 @Nonnull
157 public static ToolchainModel newInstance() {
158 return newInstance(true);
159 }
160
161 /**
162 * Creates a new {@code ToolchainModel} instance using default values or not.
163 * Equivalent to {@code newBuilder(withDefaults).build()}.
164 *
165 * @param withDefaults the boolean indicating whether default values should be used
166 * @return a new {@code ToolchainModel}
167 */
168 @Nonnull
169 public static ToolchainModel newInstance(boolean withDefaults) {
170 return newBuilder(withDefaults).build();
171 }
172
173 /**
174 * Creates a new {@code ToolchainModel} builder instance.
175 * Equivalent to {@code newBuilder(true)}.
176 * @see #newBuilder(boolean)
177 *
178 * @return a new {@code Builder}
179 */
180 @Nonnull
181 public static Builder newBuilder() {
182 return newBuilder(true);
183 }
184
185 /**
186 * Creates a new {@code ToolchainModel} builder instance using default values or not.
187 *
188 * @param withDefaults the boolean indicating whether default values should be used
189 * @return a new {@code Builder}
190 */
191 @Nonnull
192 public static Builder newBuilder(boolean withDefaults) {
193 return new Builder(withDefaults);
194 }
195
196 /**
197 * Creates a new {@code ToolchainModel} builder instance using the specified object as a basis.
198 * Equivalent to {@code newBuilder(from, false)}.
199 *
200 * @param from the {@code ToolchainModel} instance to use as a basis
201 * @return a new {@code Builder}
202 */
203 @Nonnull
204 public static Builder newBuilder(ToolchainModel from) {
205 return newBuilder(from, false);
206 }
207
208 /**
209 * Creates a new {@code ToolchainModel} builder instance using the specified object as a basis.
210 *
211 * @param from the {@code ToolchainModel} instance to use as a basis
212 * @param forceCopy the boolean indicating if a copy should be forced
213 * @return a new {@code Builder}
214 */
215 @Nonnull
216 public static Builder newBuilder(ToolchainModel from, boolean forceCopy) {
217 return new Builder(from, forceCopy);
218 }
219
220 /**
221 * Builder class used to create ToolchainModel instances.
222 * @see #with()
223 * @see #newBuilder()
224 */
225 @NotThreadSafe
226 public static class Builder
227 extends TrackableBase.Builder
228 {
229 ToolchainModel base;
230 String type;
231 Map<String, String> provides;
232 XmlNode configuration;
233
234 Builder(boolean withDefaults) {
235 super(withDefaults);
236 if (withDefaults) {
237 }
238 }
239
240 Builder(ToolchainModel base, boolean forceCopy) {
241 super(base, forceCopy);
242 if (forceCopy) {
243 this.type = base.type;
244 this.provides = base.provides;
245 this.configuration = base.configuration;
246 } else {
247 this.base = base;
248 }
249 }
250
251 @Nonnull
252 public Builder type(String type) {
253 this.type = type;
254 return this;
255 }
256
257 @Nonnull
258 public Builder provides(Map<String, String> provides) {
259 this.provides = provides;
260 return this;
261 }
262
263 @Nonnull
264 public Builder configuration(XmlNode configuration) {
265 this.configuration = configuration;
266 return this;
267 }
268
269
270 @Nonnull
271 public ToolchainModel build() {
272 if (base != null
273 && (type == null || type == base.type)
274 && (provides == null || provides == base.provides)
275 && (configuration == null || configuration == base.configuration)
276 ) {
277 return base;
278 }
279 return new ToolchainModel(
280 type != null ? type : (base != null ? base.type : null),
281 provides != null ? provides : (base != null ? base.provides : null),
282 configuration != null ? configuration : (base != null ? base.configuration : null)
283 );
284 }
285 }
286
287
288
289 /**
290 * Method hashCode.
291 *
292 * @return int
293 */
294 public int hashCode()
295 {
296 int result = 17;
297
298 result = 37 * result + ( getType() != null ? getType().hashCode() : 0 );
299 result = 37 * result + ( getProvides() != null ? getProvides().hashCode() : 0 );
300
301 return result;
302 } //-- int hashCode()
303
304 /**
305 * Method equals.
306 *
307 * @param other
308 * @return boolean
309 */
310 public boolean equals( Object other )
311 {
312 if ( this == other )
313 {
314 return true;
315 }
316
317 if ( !( other instanceof ToolchainModel ) )
318 {
319 return false;
320 }
321
322 ToolchainModel that = (ToolchainModel) other;
323 boolean result = true;
324
325 result = result && ( getType() == null ? that.getType() == null : getType().equals( that.getType() ) );
326 result = result && ( getProvides() == null ? that.getProvides() == null : getProvides().equals( that.getProvides() ) );
327
328 return result;
329 } //-- boolean equals( Object )
330
331
332 }