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.artifact.repository.metadata.v4;
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 * Mapping information for a single plugin within this group.
20 */
21 @Experimental
22 @Generated @ThreadSafe @Immutable
23 public class Plugin
24 implements Serializable
25 {
26 /**
27 * Display name for the plugin.
28 */
29 final String name;
30 /**
31 * The plugin invocation prefix (i.e. eclipse for eclipse:eclipse)
32 */
33 final String prefix;
34 /**
35 * The plugin artifactId
36 */
37 final String artifactId;
38
39 /**
40 * Constructor for this class, package protected.
41 * @see Builder#build()
42 */
43 Plugin(
44 String name,
45 String prefix,
46 String artifactId
47 ) {
48 this.name = name;
49 this.prefix = prefix;
50 this.artifactId = artifactId;
51 }
52
53 /**
54 * Display name for the plugin.
55 *
56 * @return a {@code String}
57 */
58 public String getName() {
59 return this.name;
60 }
61
62 /**
63 * The plugin invocation prefix (i.e. eclipse for eclipse:eclipse)
64 *
65 * @return a {@code String}
66 */
67 public String getPrefix() {
68 return this.prefix;
69 }
70
71 /**
72 * The plugin artifactId
73 *
74 * @return a {@code String}
75 */
76 public String getArtifactId() {
77 return this.artifactId;
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 Plugin} instance using the specified name.
91 *
92 * @param name the new {@code String} to use
93 * @return a {@code Plugin} with the specified name
94 */
95 @Nonnull
96 public Plugin withName(String name) {
97 return newBuilder(this, true).name(name).build();
98 }
99 /**
100 * Creates a new {@code Plugin} instance using the specified prefix.
101 *
102 * @param prefix the new {@code String} to use
103 * @return a {@code Plugin} with the specified prefix
104 */
105 @Nonnull
106 public Plugin withPrefix(String prefix) {
107 return newBuilder(this, true).prefix(prefix).build();
108 }
109 /**
110 * Creates a new {@code Plugin} instance using the specified artifactId.
111 *
112 * @param artifactId the new {@code String} to use
113 * @return a {@code Plugin} with the specified artifactId
114 */
115 @Nonnull
116 public Plugin withArtifactId(String artifactId) {
117 return newBuilder(this, true).artifactId(artifactId).build();
118 }
119
120 /**
121 * Creates a new {@code Plugin} instance.
122 * Equivalent to {@code newInstance(true)}.
123 * @see #newInstance(boolean)
124 *
125 * @return a new {@code Plugin}
126 */
127 @Nonnull
128 public static Plugin newInstance() {
129 return newInstance(true);
130 }
131
132 /**
133 * Creates a new {@code Plugin} 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 Plugin}
138 */
139 @Nonnull
140 public static Plugin newInstance(boolean withDefaults) {
141 return newBuilder(withDefaults).build();
142 }
143
144 /**
145 * Creates a new {@code Plugin} 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 Plugin} 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 Plugin} builder instance using the specified object as a basis.
169 * Equivalent to {@code newBuilder(from, false)}.
170 *
171 * @param from the {@code Plugin} instance to use as a basis
172 * @return a new {@code Builder}
173 */
174 @Nonnull
175 public static Builder newBuilder(Plugin from) {
176 return newBuilder(from, false);
177 }
178
179 /**
180 * Creates a new {@code Plugin} builder instance using the specified object as a basis.
181 *
182 * @param from the {@code Plugin} 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(Plugin from, boolean forceCopy) {
188 return new Builder(from, forceCopy);
189 }
190
191 /**
192 * Builder class used to create Plugin instances.
193 * @see #with()
194 * @see #newBuilder()
195 */
196 @NotThreadSafe
197 public static class Builder
198 {
199 Plugin base;
200 String name;
201 String prefix;
202 String artifactId;
203
204 Builder(boolean withDefaults) {
205 if (withDefaults) {
206 }
207 }
208
209 Builder(Plugin base, boolean forceCopy) {
210 if (forceCopy) {
211 this.name = base.name;
212 this.prefix = base.prefix;
213 this.artifactId = base.artifactId;
214 } else {
215 this.base = base;
216 }
217 }
218
219 @Nonnull
220 public Builder name(String name) {
221 this.name = name;
222 return this;
223 }
224
225 @Nonnull
226 public Builder prefix(String prefix) {
227 this.prefix = prefix;
228 return this;
229 }
230
231 @Nonnull
232 public Builder artifactId(String artifactId) {
233 this.artifactId = artifactId;
234 return this;
235 }
236
237
238 @Nonnull
239 public Plugin build() {
240 if (base != null
241 && (name == null || name == base.name)
242 && (prefix == null || prefix == base.prefix)
243 && (artifactId == null || artifactId == base.artifactId)
244 ) {
245 return base;
246 }
247 return new Plugin(
248 name != null ? name : (base != null ? base.name : null),
249 prefix != null ? prefix : (base != null ? base.prefix : null),
250 artifactId != null ? artifactId : (base != null ? base.artifactId : null)
251 );
252 }
253 }
254
255 }