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