View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model-v3.vm
3   //  template, any modifications will be overwritten.
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.stream.Collectors;
15  import java.util.stream.Stream;
16  import org.apache.maven.api.annotations.Generated;
17  import org.apache.maven.api.annotations.Nonnull;
18  
19  @Generated
20  public class Repository
21      extends RepositoryBase
22      implements Serializable, Cloneable
23  {
24  
25      public Repository() {
26          this(org.apache.maven.api.model.Repository.newInstance());
27      }
28  
29      public Repository(org.apache.maven.api.model.Repository delegate) {
30          this(delegate, null);
31      }
32  
33      public Repository(org.apache.maven.api.model.Repository delegate, BaseObject parent) {
34          super(delegate, parent);
35      }
36  
37      public Repository clone(){
38          return new Repository(getDelegate());
39      }
40  
41      @Override
42      public org.apache.maven.api.model.Repository getDelegate() {
43          return (org.apache.maven.api.model.Repository) super.getDelegate();
44      }
45  
46      @Override
47      public boolean equals(Object o) {
48          if (this == o) {
49              return true;
50          }
51          if (o == null || !(o instanceof Repository)) {
52              return false;
53          }
54          Repository that = (Repository) o;
55          return Objects.equals(this.delegate, that.delegate);
56      }
57  
58      @Override
59      public int hashCode() {
60          return getDelegate().hashCode();
61      }
62  
63      public RepositoryPolicy getReleases() {
64          return getDelegate().getReleases() != null ? new RepositoryPolicy(getDelegate().getReleases(), this) : null;
65      }
66  
67      public void setReleases(RepositoryPolicy releases) {
68          if (!Objects.equals(releases, getReleases())) {
69              update(getDelegate().withReleases(releases.getDelegate()));
70              releases.childrenTracking = this::replace;
71          }
72      }
73  
74      public RepositoryPolicy getSnapshots() {
75          return getDelegate().getSnapshots() != null ? new RepositoryPolicy(getDelegate().getSnapshots(), this) : null;
76      }
77  
78      public void setSnapshots(RepositoryPolicy snapshots) {
79          if (!Objects.equals(snapshots, getSnapshots())) {
80              update(getDelegate().withSnapshots(snapshots.getDelegate()));
81              snapshots.childrenTracking = this::replace;
82          }
83      }
84  
85      public InputLocation getLocation(Object key) {
86          org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
87          return loc != null ? new InputLocation(loc) : null;
88      }
89  
90      public void setLocation(Object key, InputLocation location) {
91          update(org.apache.maven.api.model.Repository.newBuilder(getDelegate(), true)
92                          .location(key, location.toApiLocation()).build());
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.model.RepositoryPolicy) newDelegate));
101             return true;
102         }
103         if (oldDelegate == getDelegate().getSnapshots()) {
104             update(getDelegate().withSnapshots((org.apache.maven.api.model.RepositoryPolicy) newDelegate));
105             return true;
106         }
107         return false;
108     }
109 
110     public static List<org.apache.maven.api.model.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.model.Repository> list) {
115         return list != null ? new WrapperList<>(list, Repository::new, Repository::getDelegate) : null;
116     }
117 
118 }