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.plugin.descriptor;
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
18 /**
19 * Describes a component requirement.
20 */
21 @Experimental
22 @Generated @ThreadSafe @Immutable
23 public class Requirement
24 implements Serializable
25 {
26 /**
27 *
28 */
29 final String role;
30 /**
31 *
32 */
33 final String roleHint;
34 /**
35 * The field name which has this requirement.
36 */
37 final String fieldName;
38
39 /**
40 * Constructor for this class, package protected.
41 * @see Builder#build()
42 */
43 Requirement(
44 String role,
45 String roleHint,
46 String fieldName
47 ) {
48 this.role = role;
49 this.roleHint = roleHint;
50 this.fieldName = fieldName;
51 }
52
53 /**
54 *
55 *
56 * @return a {@code String}
57 */
58 public String getRole() {
59 return this.role;
60 }
61
62 /**
63 *
64 *
65 * @return a {@code String}
66 */
67 public String getRoleHint() {
68 return this.roleHint;
69 }
70
71 /**
72 * The field name which has this requirement.
73 *
74 * @return a {@code String}
75 */
76 public String getFieldName() {
77 return this.fieldName;
78 }
79
80 /**
81 * Creates a new builder with this object as the basis.
82 *
83 * @return a {@code Builder}
84 */
85 @Nonnull
86 public Builder with() {
87 return newBuilder(this);
88 }
89 /**
90 * Creates a new {@code Requirement} instance using the specified role.
91 *
92 * @param role the new {@code String} to use
93 * @return a {@code Requirement} with the specified role
94 */
95 @Nonnull
96 public Requirement withRole(String role) {
97 return newBuilder(this, true).role(role).build();
98 }
99 /**
100 * Creates a new {@code Requirement} instance using the specified roleHint.
101 *
102 * @param roleHint the new {@code String} to use
103 * @return a {@code Requirement} with the specified roleHint
104 */
105 @Nonnull
106 public Requirement withRoleHint(String roleHint) {
107 return newBuilder(this, true).roleHint(roleHint).build();
108 }
109 /**
110 * Creates a new {@code Requirement} instance using the specified fieldName.
111 *
112 * @param fieldName the new {@code String} to use
113 * @return a {@code Requirement} with the specified fieldName
114 */
115 @Nonnull
116 public Requirement withFieldName(String fieldName) {
117 return newBuilder(this, true).fieldName(fieldName).build();
118 }
119
120 /**
121 * Creates a new {@code Requirement} instance.
122 * Equivalent to {@code newInstance(true)}.
123 * @see #newInstance(boolean)
124 *
125 * @return a new {@code Requirement}
126 */
127 @Nonnull
128 public static Requirement newInstance() {
129 return newInstance(true);
130 }
131
132 /**
133 * Creates a new {@code Requirement} instance using default values or not.
134 * Equivalent to {@code newBuilder(withDefaults).build()}.
135 *
136 * @param withDefaults the boolean indicating whether default values should be used
137 * @return a new {@code Requirement}
138 */
139 @Nonnull
140 public static Requirement newInstance(boolean withDefaults) {
141 return newBuilder(withDefaults).build();
142 }
143
144 /**
145 * Creates a new {@code Requirement} builder instance.
146 * Equivalent to {@code newBuilder(true)}.
147 * @see #newBuilder(boolean)
148 *
149 * @return a new {@code Builder}
150 */
151 @Nonnull
152 public static Builder newBuilder() {
153 return newBuilder(true);
154 }
155
156 /**
157 * Creates a new {@code Requirement} builder instance using default values or not.
158 *
159 * @param withDefaults the boolean indicating whether default values should be used
160 * @return a new {@code Builder}
161 */
162 @Nonnull
163 public static Builder newBuilder(boolean withDefaults) {
164 return new Builder(withDefaults);
165 }
166
167 /**
168 * Creates a new {@code Requirement} builder instance using the specified object as a basis.
169 * Equivalent to {@code newBuilder(from, false)}.
170 *
171 * @param from the {@code Requirement} instance to use as a basis
172 * @return a new {@code Builder}
173 */
174 @Nonnull
175 public static Builder newBuilder(Requirement from) {
176 return newBuilder(from, false);
177 }
178
179 /**
180 * Creates a new {@code Requirement} builder instance using the specified object as a basis.
181 *
182 * @param from the {@code Requirement} instance to use as a basis
183 * @param forceCopy the boolean indicating if a copy should be forced
184 * @return a new {@code Builder}
185 */
186 @Nonnull
187 public static Builder newBuilder(Requirement from, boolean forceCopy) {
188 return new Builder(from, forceCopy);
189 }
190
191 /**
192 * Builder class used to create Requirement instances.
193 * @see #with()
194 * @see #newBuilder()
195 */
196 @NotThreadSafe
197 public static class Builder
198 {
199 Requirement base;
200 String role;
201 String roleHint;
202 String fieldName;
203
204 Builder(boolean withDefaults) {
205 if (withDefaults) {
206 }
207 }
208
209 Builder(Requirement base, boolean forceCopy) {
210 if (forceCopy) {
211 this.role = base.role;
212 this.roleHint = base.roleHint;
213 this.fieldName = base.fieldName;
214 } else {
215 this.base = base;
216 }
217 }
218
219 @Nonnull
220 public Builder role(String role) {
221 this.role = role;
222 return this;
223 }
224
225 @Nonnull
226 public Builder roleHint(String roleHint) {
227 this.roleHint = roleHint;
228 return this;
229 }
230
231 @Nonnull
232 public Builder fieldName(String fieldName) {
233 this.fieldName = fieldName;
234 return this;
235 }
236
237
238 @Nonnull
239 public Requirement build() {
240 if (base != null
241 && (role == null || role == base.role)
242 && (roleHint == null || roleHint == base.roleHint)
243 && (fieldName == null || fieldName == base.fieldName)
244 ) {
245 return base;
246 }
247 return new Requirement(
248 role != null ? role : (base != null ? base.role : null),
249 roleHint != null ? roleHint : (base != null ? base.roleHint : null),
250 fieldName != null ? fieldName : (base != null ? base.fieldName : null)
251 );
252 }
253 }
254
255 }