1
2
3
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 java.util.Objects;
12 import org.apache.maven.api.annotations.Experimental;
13 import org.apache.maven.api.annotations.Generated;
14 import org.apache.maven.api.annotations.Immutable;
15 import org.apache.maven.api.annotations.Nonnull;
16 import org.apache.maven.api.annotations.NotThreadSafe;
17 import org.apache.maven.api.annotations.ThreadSafe;
18
19
20
21
22 @Experimental
23 @Generated @ThreadSafe @Immutable
24 public class SnapshotVersion
25 implements Serializable
26 {
27
28
29
30 final String classifier;
31
32
33
34 final String extension;
35
36
37
38 final String version;
39
40
41
42 final String updated;
43
44
45
46
47
48 SnapshotVersion(
49 String classifier,
50 String extension,
51 String version,
52 String updated
53 ) {
54 this.classifier = classifier;
55 this.extension = extension;
56 this.version = version;
57 this.updated = updated;
58 }
59
60 @Override
61 public boolean equals(Object o) {
62 if (this == o) {
63 return true;
64 }
65 if (o == null || !(o instanceof SnapshotVersion)) {
66 return false;
67 }
68 SnapshotVersion that = (SnapshotVersion) o;
69 return Objects.equals( this.classifier, that.classifier ) && Objects.equals( this.extension, that.extension ) && Objects.equals( this.version, that.version ) && Objects.equals( this.updated, that.updated );
70 }
71
72 @Override
73 public int hashCode() {
74 return Objects.hash(classifier, this.extension, this.version, this.updated);
75 }
76
77
78
79
80
81
82 public String getClassifier() {
83 return this.classifier;
84 }
85
86
87
88
89
90
91 public String getExtension() {
92 return this.extension;
93 }
94
95
96
97
98
99
100 public String getVersion() {
101 return this.version;
102 }
103
104
105
106
107
108
109 public String getUpdated() {
110 return this.updated;
111 }
112
113
114
115
116
117
118 @Nonnull
119 public Builder with() {
120 return newBuilder(this);
121 }
122
123
124
125
126
127
128 @Nonnull
129 public SnapshotVersion withClassifier(String classifier) {
130 return newBuilder(this, true).classifier(classifier).build();
131 }
132
133
134
135
136
137
138 @Nonnull
139 public SnapshotVersion withExtension(String extension) {
140 return newBuilder(this, true).extension(extension).build();
141 }
142
143
144
145
146
147
148 @Nonnull
149 public SnapshotVersion withVersion(String version) {
150 return newBuilder(this, true).version(version).build();
151 }
152
153
154
155
156
157
158 @Nonnull
159 public SnapshotVersion withUpdated(String updated) {
160 return newBuilder(this, true).updated(updated).build();
161 }
162
163
164
165
166
167
168
169
170 @Nonnull
171 public static SnapshotVersion newInstance() {
172 return newInstance(true);
173 }
174
175
176
177
178
179
180
181
182 @Nonnull
183 public static SnapshotVersion newInstance(boolean withDefaults) {
184 return newBuilder(withDefaults).build();
185 }
186
187
188
189
190
191
192
193
194 @Nonnull
195 public static Builder newBuilder() {
196 return newBuilder(true);
197 }
198
199
200
201
202
203
204
205 @Nonnull
206 public static Builder newBuilder(boolean withDefaults) {
207 return new Builder(withDefaults);
208 }
209
210
211
212
213
214
215
216
217 @Nonnull
218 public static Builder newBuilder(SnapshotVersion from) {
219 return newBuilder(from, false);
220 }
221
222
223
224
225
226
227
228
229 @Nonnull
230 public static Builder newBuilder(SnapshotVersion from, boolean forceCopy) {
231 return new Builder(from, forceCopy);
232 }
233
234
235
236
237
238
239 @NotThreadSafe
240 public static class Builder
241 {
242 SnapshotVersion base;
243 String classifier;
244 String extension;
245 String version;
246 String updated;
247
248 Builder(boolean withDefaults) {
249 if (withDefaults) {
250 }
251 }
252
253 Builder(SnapshotVersion base, boolean forceCopy) {
254 if (forceCopy) {
255 this.classifier = base.classifier;
256 this.extension = base.extension;
257 this.version = base.version;
258 this.updated = base.updated;
259 } else {
260 this.base = base;
261 }
262 }
263
264 @Nonnull
265 public Builder classifier(String classifier) {
266 this.classifier = classifier;
267 return this;
268 }
269
270 @Nonnull
271 public Builder extension(String extension) {
272 this.extension = extension;
273 return this;
274 }
275
276 @Nonnull
277 public Builder version(String version) {
278 this.version = version;
279 return this;
280 }
281
282 @Nonnull
283 public Builder updated(String updated) {
284 this.updated = updated;
285 return this;
286 }
287
288
289 @Nonnull
290 public SnapshotVersion build() {
291 if (base != null
292 && (classifier == null || classifier == base.classifier)
293 && (extension == null || extension == base.extension)
294 && (version == null || version == base.version)
295 && (updated == null || updated == base.updated)
296 ) {
297 return base;
298 }
299 return new SnapshotVersion(
300 classifier != null ? classifier : (base != null ? base.classifier : null),
301 extension != null ? extension : (base != null ? base.extension : null),
302 version != null ? version : (base != null ? base.version : null),
303 updated != null ? updated : (base != null ? base.updated : null)
304 );
305 }
306 }
307
308 }