1
2
3
4 package org.apache.maven.model;
5
6 import java.io.Serializable;
7 import java.util.AbstractList;
8 import java.util.Collections;
9 import java.util.HashMap;
10 import java.util.List;
11 import java.util.Map;
12 import java.util.Objects;
13 import java.util.stream.Collectors;
14 import java.util.stream.Stream;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Nonnull;
17
18 @Generated
19 public class Repository
20 extends RepositoryBase
21 implements Serializable, Cloneable
22 {
23
24 public Repository()
25 {
26 this( org.apache.maven.api.model.Repository.newInstance() );
27 }
28
29 public Repository( org.apache.maven.api.model.Repository delegate )
30 {
31 this( delegate, null );
32 }
33
34 public Repository( org.apache.maven.api.model.Repository delegate, BaseObject parent )
35 {
36 super( delegate, parent );
37 }
38
39 public Repository clone()
40 {
41 return new Repository( getDelegate() );
42 }
43
44 @Override
45 public org.apache.maven.api.model.Repository getDelegate()
46 {
47 return ( org.apache.maven.api.model.Repository ) super.getDelegate();
48 }
49
50 @Override
51 public boolean equals( Object o )
52 {
53 if ( this == o )
54 {
55 return true;
56 }
57 if ( o == null || !( o instanceof Repository ) )
58 {
59 return false;
60 }
61 Repository that = ( Repository ) o;
62 return Objects.equals( this.delegate, that.delegate );
63 }
64
65 @Override
66 public int hashCode()
67 {
68 return getDelegate().hashCode();
69 }
70
71 public RepositoryPolicy getReleases()
72 {
73 return getDelegate().getReleases() != null ? new RepositoryPolicy( getDelegate().getReleases(), this ) : null;
74 }
75
76 public void setReleases( RepositoryPolicy releases )
77 {
78 if ( !Objects.equals( releases, getDelegate().getReleases() ) )
79 {
80 update( getDelegate().withReleases( releases.getDelegate() ) );
81 releases.childrenTracking = this::replace;
82 }
83 }
84
85 public RepositoryPolicy getSnapshots()
86 {
87 return getDelegate().getSnapshots() != null ? new RepositoryPolicy( getDelegate().getSnapshots(), this ) : null;
88 }
89
90 public void setSnapshots( RepositoryPolicy snapshots )
91 {
92 if ( !Objects.equals( snapshots, getDelegate().getSnapshots() ) )
93 {
94 update( getDelegate().withSnapshots( snapshots.getDelegate() ) );
95 snapshots.childrenTracking = this::replace;
96 }
97 }
98
99 public InputLocation getLocation( Object key )
100 {
101 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation( key );
102 return loc != null ? new InputLocation( loc ) : null;
103 }
104
105 public void setLocation( Object key, InputLocation location )
106 {
107 update( org.apache.maven.api.model.Repository.newBuilder( getDelegate(), true )
108 .location( key, location.toApiLocation() ).build() );
109 }
110
111 protected boolean replace( Object oldDelegate, Object newDelegate )
112 {
113 if ( super.replace( oldDelegate, newDelegate ) )
114 {
115 return true;
116 }
117 if ( oldDelegate == getDelegate().getReleases() )
118 {
119 update( getDelegate().withReleases( ( org.apache.maven.api.model.RepositoryPolicy ) newDelegate ) );
120 return true;
121 }
122 if ( oldDelegate == getDelegate().getSnapshots() )
123 {
124 update( getDelegate().withSnapshots( ( org.apache.maven.api.model.RepositoryPolicy ) newDelegate ) );
125 return true;
126 }
127 return false;
128 }
129
130 public static List<org.apache.maven.api.model.Repository> repositoryToApiV4( List<Repository> list )
131 {
132 return list != null ? new WrapperList<>( list, Repository::getDelegate, Repository::new ) : null;
133 }
134
135 public static List<Repository> repositoryToApiV3( List<org.apache.maven.api.model.Repository> list )
136 {
137 return list != null ? new WrapperList<>( list, Repository::new, Repository::getDelegate ) : null;
138 }
139
140 }