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      {
27          this( org.apache.maven.api.model.Repository.newInstance() );
28      }
29  
30      public Repository( org.apache.maven.api.model.Repository delegate )
31      {
32          this( delegate, null );
33      }
34  
35      public Repository( org.apache.maven.api.model.Repository delegate, BaseObject parent )
36      {
37          super( delegate, parent );
38      }
39  
40      public Repository clone()
41      {
42          return new Repository( getDelegate() );
43      }
44  
45      @Override
46      public org.apache.maven.api.model.Repository getDelegate()
47      {
48          return ( org.apache.maven.api.model.Repository ) super.getDelegate();
49      }
50  
51      @Override
52      public boolean equals( Object o )
53      {
54          if ( this == o )
55          {
56              return true;
57          }
58          if ( o == null || !( o instanceof Repository ) )
59          {
60              return false;
61          }
62          Repository that = ( Repository ) o;
63          return Objects.equals( this.delegate, that.delegate );
64      }
65  
66      @Override
67      public int hashCode()
68      {
69          return getDelegate().hashCode();
70      }
71  
72      public RepositoryPolicy getReleases()
73      {
74          return getDelegate().getReleases() != null ? new RepositoryPolicy( getDelegate().getReleases(), this ) : null;
75      }
76  
77      public void setReleases( RepositoryPolicy releases )
78      {
79          if ( !Objects.equals( releases, getDelegate().getReleases() ) )
80          {
81              update( getDelegate().withReleases( releases.getDelegate() ) );
82              releases.childrenTracking = this::replace;
83          }
84      }
85  
86      public RepositoryPolicy getSnapshots()
87      {
88          return getDelegate().getSnapshots() != null ? new RepositoryPolicy( getDelegate().getSnapshots(), this ) : null;
89      }
90  
91      public void setSnapshots( RepositoryPolicy snapshots )
92      {
93          if ( !Objects.equals( snapshots, getDelegate().getSnapshots() ) )
94          {
95              update( getDelegate().withSnapshots( snapshots.getDelegate() ) );
96              snapshots.childrenTracking = this::replace;
97          }
98      }
99  
100     public InputLocation getLocation( Object key )
101     {
102         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation( key );
103         return loc != null ? new InputLocation( loc ) : null;
104     }
105 
106     public void setLocation( Object key, InputLocation location )
107     {
108         update( org.apache.maven.api.model.Repository.newBuilder( getDelegate(), true )
109                         .location( key, location.toApiLocation() ).build() );
110     }
111 
112     protected boolean replace( Object oldDelegate, Object newDelegate )
113     {
114         if ( super.replace( oldDelegate, newDelegate ) )
115         {
116             return true;
117         }
118         if ( oldDelegate == getDelegate().getReleases() )
119         {
120             update( getDelegate().withReleases( ( org.apache.maven.api.model.RepositoryPolicy ) newDelegate ) );
121             return true;
122         }
123         if ( oldDelegate == getDelegate().getSnapshots() )
124         {
125             update( getDelegate().withSnapshots( ( org.apache.maven.api.model.RepositoryPolicy ) newDelegate ) );
126             return true;
127         }
128         return false;
129     }
130 
131     public static List<org.apache.maven.api.model.Repository> repositoryToApiV4( List<Repository> list )
132     {
133         return list != null ? new WrapperList<>( list, Repository::getDelegate, Repository::new ) : null;
134     }
135 
136     public static List<Repository> repositoryToApiV3( List<org.apache.maven.api.model.Repository> list )
137     {
138         return list != null ? new WrapperList<>( list, Repository::new, Repository::getDelegate ) : null;
139     }
140 
141 }