1
2
3
4
5 package org.apache.maven.model;
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.model.Repository.newInstance());
28 }
29
30 public Repository(org.apache.maven.api.model.Repository delegate) {
31 this(delegate, null);
32 }
33
34 public Repository(org.apache.maven.api.model.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.model.Repository getDelegate() {
44 return (org.apache.maven.api.model.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 public InputLocation getLocation(Object key) {
95 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
96 return loc != null ? new InputLocation(loc) : null;
97 }
98
99 public void setLocation(Object key, InputLocation location) {
100 update(org.apache.maven.api.model.Repository.newBuilder(getDelegate(), true)
101 .location(key, location.toApiLocation()).build());
102 }
103
104 public InputLocation getImportedFrom() {
105 org.apache.maven.api.model.InputLocation loc = getDelegate().getImportedFrom();
106 return loc != null ? new InputLocation(loc) : null;
107 }
108
109 public void setImportedFrom(InputLocation location) {
110 update(org.apache.maven.api.model.Repository.newBuilder(getDelegate(), true)
111 .importedFrom(location.toApiLocation()).build());
112 }
113
114 public Set<Object> getLocationKeys() {
115 return getDelegate().getLocationKeys();
116 }
117
118 protected boolean replace(Object oldDelegate, Object newDelegate) {
119 if (super.replace(oldDelegate, newDelegate)) {
120 return true;
121 }
122 if (oldDelegate == getDelegate().getReleases()) {
123 update(getDelegate().withReleases((org.apache.maven.api.model.RepositoryPolicy) newDelegate));
124 return true;
125 }
126 if (oldDelegate == getDelegate().getSnapshots()) {
127 update(getDelegate().withSnapshots((org.apache.maven.api.model.RepositoryPolicy) newDelegate));
128 return true;
129 }
130 return false;
131 }
132
133 public static List<org.apache.maven.api.model.Repository> repositoryToApiV4(List<Repository> list) {
134 return list != null ? new WrapperList<>(list, Repository::getDelegate, Repository::new) : null;
135 }
136
137 public static List<Repository> repositoryToApiV3(List<org.apache.maven.api.model.Repository> list) {
138 return list != null ? new WrapperList<>(list, Repository::new, Repository::getDelegate) : null;
139 }
140
141 }