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