1
2
3
4
5 package org.apache.maven.model;
6
7 import java.io.Serializable;
8 import java.nio.file.Path;
9 import java.util.AbstractList;
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.HashMap;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Objects;
16 import java.util.Properties;
17 import java.util.Set;
18 import java.util.stream.Collectors;
19 import java.util.stream.Stream;
20 import org.apache.maven.api.annotations.Generated;
21 import org.apache.maven.api.annotations.Nonnull;
22 import org.codehaus.plexus.util.xml.Xpp3Dom;
23
24 @Generated
25 public class Model
26 extends ModelBase
27 implements Serializable, Cloneable
28 {
29
30 public Model() {
31 this(org.apache.maven.api.model.Model.newInstance());
32 }
33
34 public Model(org.apache.maven.api.model.Model delegate) {
35 this(delegate, null);
36 }
37
38 public Model(org.apache.maven.api.model.Model delegate, BaseObject parent) {
39 super(delegate, parent);
40 }
41
42 public Model clone(){
43 return new Model(getDelegate());
44 }
45
46 @Override
47 public org.apache.maven.api.model.Model getDelegate() {
48 return (org.apache.maven.api.model.Model) super.getDelegate();
49 }
50
51 @Override
52 public boolean equals(Object o) {
53 if (this == o) {
54 return true;
55 }
56 if (o == null || !(o instanceof Model)) {
57 return false;
58 }
59 Model that = (Model) o;
60 return Objects.equals(this.delegate, that.delegate);
61 }
62
63 @Override
64 public int hashCode() {
65 return getDelegate().hashCode();
66 }
67
68 public String getModelEncoding() {
69 return getDelegate().getModelEncoding();
70 }
71
72 public String getModelVersion() {
73 return getDelegate().getModelVersion();
74 }
75
76 public void setModelVersion(String modelVersion) {
77 if (!Objects.equals(modelVersion, getModelVersion())) {
78 update(getDelegate().withModelVersion(modelVersion));
79 }
80 }
81
82 public Parent getParent() {
83 return getDelegate().getParent() != null ? new Parent(getDelegate().getParent(), this) : null;
84 }
85
86 public void setParent(Parent parent) {
87 if (!Objects.equals(parent, getParent())){
88 if (parent != null) {
89 update(getDelegate().withParent(parent.getDelegate()));
90 parent.childrenTracking = this::replace;
91 } else {
92 update(getDelegate().withParent(null));
93 }
94 }
95 }
96
97 public String getGroupId() {
98 return getDelegate().getGroupId();
99 }
100
101 public void setGroupId(String groupId) {
102 if (!Objects.equals(groupId, getGroupId())) {
103 update(getDelegate().withGroupId(groupId));
104 }
105 }
106
107 public String getArtifactId() {
108 return getDelegate().getArtifactId();
109 }
110
111 public void setArtifactId(String artifactId) {
112 if (!Objects.equals(artifactId, getArtifactId())) {
113 update(getDelegate().withArtifactId(artifactId));
114 }
115 }
116
117 public String getVersion() {
118 return getDelegate().getVersion();
119 }
120
121 public void setVersion(String version) {
122 if (!Objects.equals(version, getVersion())) {
123 update(getDelegate().withVersion(version));
124 }
125 }
126
127 public String getPackaging() {
128 return getDelegate().getPackaging();
129 }
130
131 public void setPackaging(String packaging) {
132 if (!Objects.equals(packaging, getPackaging())) {
133 update(getDelegate().withPackaging(packaging));
134 }
135 }
136
137 public String getName() {
138 return getDelegate().getName();
139 }
140
141 public void setName(String name) {
142 if (!Objects.equals(name, getName())) {
143 update(getDelegate().withName(name));
144 }
145 }
146
147 public String getDescription() {
148 return getDelegate().getDescription();
149 }
150
151 public void setDescription(String description) {
152 if (!Objects.equals(description, getDescription())) {
153 update(getDelegate().withDescription(description));
154 }
155 }
156
157 public String getUrl() {
158 return getDelegate().getUrl();
159 }
160
161 public void setUrl(String url) {
162 if (!Objects.equals(url, getUrl())) {
163 update(getDelegate().withUrl(url));
164 }
165 }
166
167 public String getChildProjectUrlInheritAppendPath() {
168 return getDelegate().getChildProjectUrlInheritAppendPath();
169 }
170
171 public void setChildProjectUrlInheritAppendPath(String childProjectUrlInheritAppendPath) {
172 if (!Objects.equals(childProjectUrlInheritAppendPath, getChildProjectUrlInheritAppendPath())) {
173 update(getDelegate().withChildProjectUrlInheritAppendPath(childProjectUrlInheritAppendPath));
174 }
175 }
176
177 public String getInceptionYear() {
178 return getDelegate().getInceptionYear();
179 }
180
181 public void setInceptionYear(String inceptionYear) {
182 if (!Objects.equals(inceptionYear, getInceptionYear())) {
183 update(getDelegate().withInceptionYear(inceptionYear));
184 }
185 }
186
187 public Organization getOrganization() {
188 return getDelegate().getOrganization() != null ? new Organization(getDelegate().getOrganization(), this) : null;
189 }
190
191 public void setOrganization(Organization organization) {
192 if (!Objects.equals(organization, getOrganization())){
193 if (organization != null) {
194 update(getDelegate().withOrganization(organization.getDelegate()));
195 organization.childrenTracking = this::replace;
196 } else {
197 update(getDelegate().withOrganization(null));
198 }
199 }
200 }
201
202 @Nonnull
203 public List<License> getLicenses() {
204 return new WrapperList<License, org.apache.maven.api.model.License>(
205 () -> getDelegate().getLicenses(), l -> update(getDelegate().withLicenses(l)),
206 d -> new License(d, this), License::getDelegate);
207 }
208
209 public void setLicenses(List<License> licenses) {
210 if (licenses == null) {
211 licenses = Collections.emptyList();
212 }
213 if (!Objects.equals(licenses, getLicenses())) {
214 update(getDelegate().withLicenses(
215 licenses.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
216 licenses.forEach(e -> e.childrenTracking = this::replace);
217 }
218 }
219
220 public void addLicense(License license) {
221 update(getDelegate().withLicenses(
222 Stream.concat(getDelegate().getLicenses().stream(), Stream.of(license.getDelegate()))
223 .collect(Collectors.toList())));
224 license.childrenTracking = this::replace;
225 }
226
227 public void removeLicense(License license) {
228 update(getDelegate().withLicenses(
229 getDelegate().getLicenses().stream()
230 .filter(e -> !Objects.equals(e, license))
231 .collect(Collectors.toList())));
232 license.childrenTracking = null;
233 }
234
235 @Nonnull
236 public List<Developer> getDevelopers() {
237 return new WrapperList<Developer, org.apache.maven.api.model.Developer>(
238 () -> getDelegate().getDevelopers(), l -> update(getDelegate().withDevelopers(l)),
239 d -> new Developer(d, this), Developer::getDelegate);
240 }
241
242 public void setDevelopers(List<Developer> developers) {
243 if (developers == null) {
244 developers = Collections.emptyList();
245 }
246 if (!Objects.equals(developers, getDevelopers())) {
247 update(getDelegate().withDevelopers(
248 developers.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
249 developers.forEach(e -> e.childrenTracking = this::replace);
250 }
251 }
252
253 public void addDeveloper(Developer developer) {
254 update(getDelegate().withDevelopers(
255 Stream.concat(getDelegate().getDevelopers().stream(), Stream.of(developer.getDelegate()))
256 .collect(Collectors.toList())));
257 developer.childrenTracking = this::replace;
258 }
259
260 public void removeDeveloper(Developer developer) {
261 update(getDelegate().withDevelopers(
262 getDelegate().getDevelopers().stream()
263 .filter(e -> !Objects.equals(e, developer))
264 .collect(Collectors.toList())));
265 developer.childrenTracking = null;
266 }
267
268 @Nonnull
269 public List<Contributor> getContributors() {
270 return new WrapperList<Contributor, org.apache.maven.api.model.Contributor>(
271 () -> getDelegate().getContributors(), l -> update(getDelegate().withContributors(l)),
272 d -> new Contributor(d, this), Contributor::getDelegate);
273 }
274
275 public void setContributors(List<Contributor> contributors) {
276 if (contributors == null) {
277 contributors = Collections.emptyList();
278 }
279 if (!Objects.equals(contributors, getContributors())) {
280 update(getDelegate().withContributors(
281 contributors.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
282 contributors.forEach(e -> e.childrenTracking = this::replace);
283 }
284 }
285
286 public void addContributor(Contributor contributor) {
287 update(getDelegate().withContributors(
288 Stream.concat(getDelegate().getContributors().stream(), Stream.of(contributor.getDelegate()))
289 .collect(Collectors.toList())));
290 contributor.childrenTracking = this::replace;
291 }
292
293 public void removeContributor(Contributor contributor) {
294 update(getDelegate().withContributors(
295 getDelegate().getContributors().stream()
296 .filter(e -> !Objects.equals(e, contributor))
297 .collect(Collectors.toList())));
298 contributor.childrenTracking = null;
299 }
300
301 @Nonnull
302 public List<MailingList> getMailingLists() {
303 return new WrapperList<MailingList, org.apache.maven.api.model.MailingList>(
304 () -> getDelegate().getMailingLists(), l -> update(getDelegate().withMailingLists(l)),
305 d -> new MailingList(d, this), MailingList::getDelegate);
306 }
307
308 public void setMailingLists(List<MailingList> mailingLists) {
309 if (mailingLists == null) {
310 mailingLists = Collections.emptyList();
311 }
312 if (!Objects.equals(mailingLists, getMailingLists())) {
313 update(getDelegate().withMailingLists(
314 mailingLists.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
315 mailingLists.forEach(e -> e.childrenTracking = this::replace);
316 }
317 }
318
319 public void addMailingList(MailingList mailingList) {
320 update(getDelegate().withMailingLists(
321 Stream.concat(getDelegate().getMailingLists().stream(), Stream.of(mailingList.getDelegate()))
322 .collect(Collectors.toList())));
323 mailingList.childrenTracking = this::replace;
324 }
325
326 public void removeMailingList(MailingList mailingList) {
327 update(getDelegate().withMailingLists(
328 getDelegate().getMailingLists().stream()
329 .filter(e -> !Objects.equals(e, mailingList))
330 .collect(Collectors.toList())));
331 mailingList.childrenTracking = null;
332 }
333
334 public Prerequisites getPrerequisites() {
335 return getDelegate().getPrerequisites() != null ? new Prerequisites(getDelegate().getPrerequisites(), this) : null;
336 }
337
338 public void setPrerequisites(Prerequisites prerequisites) {
339 if (!Objects.equals(prerequisites, getPrerequisites())){
340 if (prerequisites != null) {
341 update(getDelegate().withPrerequisites(prerequisites.getDelegate()));
342 prerequisites.childrenTracking = this::replace;
343 } else {
344 update(getDelegate().withPrerequisites(null));
345 }
346 }
347 }
348
349 public Scm getScm() {
350 return getDelegate().getScm() != null ? new Scm(getDelegate().getScm(), this) : null;
351 }
352
353 public void setScm(Scm scm) {
354 if (!Objects.equals(scm, getScm())){
355 if (scm != null) {
356 update(getDelegate().withScm(scm.getDelegate()));
357 scm.childrenTracking = this::replace;
358 } else {
359 update(getDelegate().withScm(null));
360 }
361 }
362 }
363
364 public IssueManagement getIssueManagement() {
365 return getDelegate().getIssueManagement() != null ? new IssueManagement(getDelegate().getIssueManagement(), this) : null;
366 }
367
368 public void setIssueManagement(IssueManagement issueManagement) {
369 if (!Objects.equals(issueManagement, getIssueManagement())){
370 if (issueManagement != null) {
371 update(getDelegate().withIssueManagement(issueManagement.getDelegate()));
372 issueManagement.childrenTracking = this::replace;
373 } else {
374 update(getDelegate().withIssueManagement(null));
375 }
376 }
377 }
378
379 public CiManagement getCiManagement() {
380 return getDelegate().getCiManagement() != null ? new CiManagement(getDelegate().getCiManagement(), this) : null;
381 }
382
383 public void setCiManagement(CiManagement ciManagement) {
384 if (!Objects.equals(ciManagement, getCiManagement())){
385 if (ciManagement != null) {
386 update(getDelegate().withCiManagement(ciManagement.getDelegate()));
387 ciManagement.childrenTracking = this::replace;
388 } else {
389 update(getDelegate().withCiManagement(null));
390 }
391 }
392 }
393
394 public Build getBuild() {
395 return getDelegate().getBuild() != null ? new Build(getDelegate().getBuild(), this) : null;
396 }
397
398 public void setBuild(Build build) {
399 if (!Objects.equals(build, getBuild())){
400 if (build != null) {
401 update(getDelegate().withBuild(build.getDelegate()));
402 build.childrenTracking = this::replace;
403 } else {
404 update(getDelegate().withBuild(null));
405 }
406 }
407 }
408
409 @Nonnull
410 public List<Profile> getProfiles() {
411 return new WrapperList<Profile, org.apache.maven.api.model.Profile>(
412 () -> getDelegate().getProfiles(), l -> update(getDelegate().withProfiles(l)),
413 d -> new Profile(d, this), Profile::getDelegate);
414 }
415
416 public void setProfiles(List<Profile> profiles) {
417 if (profiles == null) {
418 profiles = Collections.emptyList();
419 }
420 if (!Objects.equals(profiles, getProfiles())) {
421 update(getDelegate().withProfiles(
422 profiles.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
423 profiles.forEach(e -> e.childrenTracking = this::replace);
424 }
425 }
426
427 public void addProfile(Profile profile) {
428 update(getDelegate().withProfiles(
429 Stream.concat(getDelegate().getProfiles().stream(), Stream.of(profile.getDelegate()))
430 .collect(Collectors.toList())));
431 profile.childrenTracking = this::replace;
432 }
433
434 public void removeProfile(Profile profile) {
435 update(getDelegate().withProfiles(
436 getDelegate().getProfiles().stream()
437 .filter(e -> !Objects.equals(e, profile))
438 .collect(Collectors.toList())));
439 profile.childrenTracking = null;
440 }
441
442 public InputLocation getLocation(Object key) {
443 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
444 return loc != null ? new InputLocation(loc) : null;
445 }
446
447 public void setLocation(Object key, InputLocation location) {
448 update(org.apache.maven.api.model.Model.newBuilder(getDelegate(), true)
449 .location(key, location.toApiLocation()).build());
450 }
451
452 public InputLocation getImportedFrom() {
453 org.apache.maven.api.model.InputLocation loc = getDelegate().getImportedFrom();
454 return loc != null ? new InputLocation(loc) : null;
455 }
456
457 public void setImportedFrom(InputLocation location) {
458 update(org.apache.maven.api.model.Model.newBuilder(getDelegate(), true)
459 .importedFrom(location.toApiLocation()).build());
460 }
461
462 public Set<Object> getLocationKeys() {
463 return getDelegate().getLocationKeys();
464 }
465
466 protected boolean replace(Object oldDelegate, Object newDelegate) {
467 if (super.replace(oldDelegate, newDelegate)) {
468 return true;
469 }
470 if (oldDelegate == getDelegate().getParent()) {
471 update(getDelegate().withParent((org.apache.maven.api.model.Parent) newDelegate));
472 return true;
473 }
474 if (oldDelegate == getDelegate().getOrganization()) {
475 update(getDelegate().withOrganization((org.apache.maven.api.model.Organization) newDelegate));
476 return true;
477 }
478 if (getDelegate().getLicenses().contains(oldDelegate)) {
479 List<org.apache.maven.api.model.License> list = new ArrayList<>(getDelegate().getLicenses());
480 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.License) newDelegate : d);
481 update(getDelegate().withLicenses(list));
482 return true;
483 }
484 if (getDelegate().getDevelopers().contains(oldDelegate)) {
485 List<org.apache.maven.api.model.Developer> list = new ArrayList<>(getDelegate().getDevelopers());
486 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Developer) newDelegate : d);
487 update(getDelegate().withDevelopers(list));
488 return true;
489 }
490 if (getDelegate().getContributors().contains(oldDelegate)) {
491 List<org.apache.maven.api.model.Contributor> list = new ArrayList<>(getDelegate().getContributors());
492 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Contributor) newDelegate : d);
493 update(getDelegate().withContributors(list));
494 return true;
495 }
496 if (getDelegate().getMailingLists().contains(oldDelegate)) {
497 List<org.apache.maven.api.model.MailingList> list = new ArrayList<>(getDelegate().getMailingLists());
498 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.MailingList) newDelegate : d);
499 update(getDelegate().withMailingLists(list));
500 return true;
501 }
502 if (oldDelegate == getDelegate().getPrerequisites()) {
503 update(getDelegate().withPrerequisites((org.apache.maven.api.model.Prerequisites) newDelegate));
504 return true;
505 }
506 if (oldDelegate == getDelegate().getScm()) {
507 update(getDelegate().withScm((org.apache.maven.api.model.Scm) newDelegate));
508 return true;
509 }
510 if (oldDelegate == getDelegate().getIssueManagement()) {
511 update(getDelegate().withIssueManagement((org.apache.maven.api.model.IssueManagement) newDelegate));
512 return true;
513 }
514 if (oldDelegate == getDelegate().getCiManagement()) {
515 update(getDelegate().withCiManagement((org.apache.maven.api.model.CiManagement) newDelegate));
516 return true;
517 }
518 if (oldDelegate == getDelegate().getBuild()) {
519 update(getDelegate().withBuild((org.apache.maven.api.model.Build) newDelegate));
520 return true;
521 }
522 if (getDelegate().getProfiles().contains(oldDelegate)) {
523 List<org.apache.maven.api.model.Profile> list = new ArrayList<>(getDelegate().getProfiles());
524 list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Profile) newDelegate : d);
525 update(getDelegate().withProfiles(list));
526 return true;
527 }
528 return false;
529 }
530
531 public static List<org.apache.maven.api.model.Model> modelToApiV4(List<Model> list) {
532 return list != null ? new WrapperList<>(list, Model::getDelegate, Model::new) : null;
533 }
534
535 public static List<Model> modelToApiV3(List<org.apache.maven.api.model.Model> list) {
536 return list != null ? new WrapperList<>(list, Model::new, Model::getDelegate) : null;
537 }
538
539
540
541
542
543
544
545
546
547 @Deprecated
548 public java.io.File getPomFile() {
549 return (getDelegate().getPomFile() != null) ? getDelegate().getPomFile().toFile() : null;
550 }
551
552 @Deprecated
553 public void setPomFile(java.io.File pomFile) {
554 update( getDelegate().withPomFile(pomFile != null ? pomFile.toPath() : null));
555 }
556
557
558
559
560
561
562
563 public java.nio.file.Path getPomPath() {
564 return (getDelegate().getPomFile() != null) ? getDelegate().getPomFile() : null;
565 }
566
567 public void setPomPath(java.nio.file.Path pomPath) {
568 update( getDelegate().withPomFile(pomPath));
569 }
570
571 public void setModelEncoding(String modelEncoding) {
572 update(getDelegate().with().modelEncoding(modelEncoding).build());
573 }
574
575
576
577
578
579
580
581 @Deprecated
582 public java.io.File getProjectDirectory() {
583 return (getDelegate().getProjectDirectory() != null) ? getDelegate().getProjectDirectory().toFile() : null;
584 }
585
586
587
588
589
590
591
592 public java.nio.file.Path getProjectDirectoryPath() {
593 return getDelegate().getProjectDirectory();
594 }
595
596
597
598
599 public String getId() {
600 StringBuilder id = new StringBuilder( 64 );
601
602 id.append( ( getGroupId() == null ) ? "[inherited]" : getGroupId() );
603 id.append( ":" );
604 id.append( getArtifactId() );
605 id.append( ":" );
606 id.append( getPackaging() );
607 id.append( ":" );
608 id.append( ( getVersion() == null ) ? "[inherited]" : getVersion() );
609
610 return id.toString();
611 }
612
613 @Override
614 public String toString() {
615 return getId();
616 }
617
618 public boolean isChildProjectUrlInheritAppendPath() {
619 return getDelegate().isChildProjectUrlInheritAppendPath();
620 }
621
622 public void setChildProjectUrlInheritAppendPath(boolean childProjectUrlInheritAppendPath) {
623 delegate = getDelegate().withChildProjectUrlInheritAppendPath(String.valueOf(childProjectUrlInheritAppendPath));
624 }
625
626
627
628 }