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