1
2
3
4
5 package org.apache.maven.settings;
6
7 import java.io.Serializable;
8 import java.util.AbstractList;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.List;
12 import java.util.Map;
13 import java.util.Objects;
14 import java.util.Set;
15 import java.util.stream.Collectors;
16 import java.util.stream.Stream;
17 import org.apache.maven.api.annotations.Generated;
18 import org.apache.maven.api.annotations.Nonnull;
19
20 @Generated
21 public class Repository
22 extends RepositoryBase
23 implements Serializable, Cloneable
24 {
25
26 public Repository() {
27 this(org.apache.maven.api.settings.Repository.newInstance());
28 }
29
30 public Repository(org.apache.maven.api.settings.Repository delegate) {
31 this(delegate, null);
32 }
33
34 public Repository(org.apache.maven.api.settings.Repository delegate, BaseObject parent) {
35 super(delegate, parent);
36 }
37
38 public Repository clone(){
39 return new Repository(getDelegate());
40 }
41
42 @Override
43 public org.apache.maven.api.settings.Repository getDelegate() {
44 return (org.apache.maven.api.settings.Repository) super.getDelegate();
45 }
46
47 @Override
48 public boolean equals(Object o) {
49 if (this == o) {
50 return true;
51 }
52 if (o == null || !(o instanceof Repository)) {
53 return false;
54 }
55 Repository that = (Repository) o;
56 return Objects.equals(this.delegate, that.delegate);
57 }
58
59 @Override
60 public int hashCode() {
61 return getDelegate().hashCode();
62 }
63
64 public RepositoryPolicy getReleases() {
65 return getDelegate().getReleases() != null ? new RepositoryPolicy(getDelegate().getReleases(), this) : null;
66 }
67
68 public void setReleases(RepositoryPolicy releases) {
69 if (!Objects.equals(releases, getReleases())){
70 if (releases != null) {
71 update(getDelegate().withReleases(releases.getDelegate()));
72 releases.childrenTracking = this::replace;
73 } else {
74 update(getDelegate().withReleases(null));
75 }
76 }
77 }
78
79 public RepositoryPolicy getSnapshots() {
80 return getDelegate().getSnapshots() != null ? new RepositoryPolicy(getDelegate().getSnapshots(), this) : null;
81 }
82
83 public void setSnapshots(RepositoryPolicy snapshots) {
84 if (!Objects.equals(snapshots, getSnapshots())){
85 if (snapshots != null) {
86 update(getDelegate().withSnapshots(snapshots.getDelegate()));
87 snapshots.childrenTracking = this::replace;
88 } else {
89 update(getDelegate().withSnapshots(null));
90 }
91 }
92 }
93
94 protected boolean replace(Object oldDelegate, Object newDelegate) {
95 if (super.replace(oldDelegate, newDelegate)) {
96 return true;
97 }
98 if (oldDelegate == getDelegate().getReleases()) {
99 update(getDelegate().withReleases((org.apache.maven.api.settings.RepositoryPolicy) newDelegate));
100 return true;
101 }
102 if (oldDelegate == getDelegate().getSnapshots()) {
103 update(getDelegate().withSnapshots((org.apache.maven.api.settings.RepositoryPolicy) newDelegate));
104 return true;
105 }
106 return false;
107 }
108
109 public static List<org.apache.maven.api.settings.Repository> repositoryToApiV4(List<Repository> list) {
110 return list != null ? new WrapperList<>(list, Repository::getDelegate, Repository::new) : null;
111 }
112
113 public static List<Repository> repositoryToApiV3(List<org.apache.maven.api.settings.Repository> list) {
114 return list != null ? new WrapperList<>(list, Repository::new, Repository::getDelegate) : null;
115 }
116
117 }