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.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.settings.Repository.newInstance() );
28 }
29
30 public Repository( org.apache.maven.api.settings.Repository delegate )
31 {
32 this( delegate, null );
33 }
34
35 public Repository( org.apache.maven.api.settings.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.settings.Repository getDelegate()
47 {
48 return ( org.apache.maven.api.settings.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 protected boolean replace( Object oldDelegate, Object newDelegate )
101 {
102 if ( super.replace( oldDelegate, newDelegate ) )
103 {
104 return true;
105 }
106 if ( oldDelegate == getDelegate().getReleases() )
107 {
108 update( getDelegate().withReleases( ( org.apache.maven.api.settings.RepositoryPolicy ) newDelegate ) );
109 return true;
110 }
111 if ( oldDelegate == getDelegate().getSnapshots() )
112 {
113 update( getDelegate().withSnapshots( ( org.apache.maven.api.settings.RepositoryPolicy ) newDelegate ) );
114 return true;
115 }
116 return false;
117 }
118
119 public static List<org.apache.maven.api.settings.Repository> repositoryToApiV4( List<Repository> list )
120 {
121 return list != null ? new WrapperList<>( list, Repository::getDelegate, Repository::new ) : null;
122 }
123
124 public static List<Repository> repositoryToApiV3( List<org.apache.maven.api.settings.Repository> list )
125 {
126 return list != null ? new WrapperList<>( list, Repository::new, Repository::getDelegate ) : null;
127 }
128
129 }