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.ArrayList;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import java.util.Objects;
15 import java.util.Properties;
16 import java.util.stream.Collectors;
17 import java.util.stream.Stream;
18 import org.apache.maven.api.annotations.Generated;
19 import org.apache.maven.api.annotations.Nonnull;
20
21 @Generated
22 public class Contributor
23 extends BaseObject
24 {
25
26 public Contributor()
27 {
28 this( org.apache.maven.api.model.Contributor.newInstance() );
29 }
30
31 public Contributor( org.apache.maven.api.model.Contributor delegate )
32 {
33 this( delegate, null );
34 }
35
36 public Contributor( org.apache.maven.api.model.Contributor delegate, BaseObject parent )
37 {
38 super( delegate, parent );
39 }
40
41 public Contributor clone()
42 {
43 return new Contributor( getDelegate() );
44 }
45
46 public org.apache.maven.api.model.Contributor getDelegate()
47 {
48 return ( org.apache.maven.api.model.Contributor ) 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 Contributor ) )
59 {
60 return false;
61 }
62 Contributor that = ( Contributor ) 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 String getName()
73 {
74 return getDelegate().getName();
75 }
76
77 public void setName( String name )
78 {
79 if ( !Objects.equals( name, getDelegate().getName() ) )
80 {
81 update( getDelegate().withName( name ) );
82 }
83 }
84
85 public String getEmail()
86 {
87 return getDelegate().getEmail();
88 }
89
90 public void setEmail( String email )
91 {
92 if ( !Objects.equals( email, getDelegate().getEmail() ) )
93 {
94 update( getDelegate().withEmail( email ) );
95 }
96 }
97
98 public String getUrl()
99 {
100 return getDelegate().getUrl();
101 }
102
103 public void setUrl( String url )
104 {
105 if ( !Objects.equals( url, getDelegate().getUrl() ) )
106 {
107 update( getDelegate().withUrl( url ) );
108 }
109 }
110
111 public String getOrganization()
112 {
113 return getDelegate().getOrganization();
114 }
115
116 public void setOrganization( String organization )
117 {
118 if ( !Objects.equals( organization, getDelegate().getOrganization() ) )
119 {
120 update( getDelegate().withOrganization( organization ) );
121 }
122 }
123
124 public String getOrganizationUrl()
125 {
126 return getDelegate().getOrganizationUrl();
127 }
128
129 public void setOrganizationUrl( String organizationUrl )
130 {
131 if ( !Objects.equals( organizationUrl, getDelegate().getOrganizationUrl() ) )
132 {
133 update( getDelegate().withOrganizationUrl( organizationUrl ) );
134 }
135 }
136
137 @Nonnull
138 public List<String> getRoles()
139 {
140 return new WrapperList<String, String>( () -> getDelegate().getRoles(), this::setRoles, s -> s, s -> s );
141 }
142
143 public void setRoles( List<String> roles )
144 {
145 if ( !Objects.equals( roles, getDelegate().getRoles() ) )
146 {
147 update( getDelegate().withRoles( roles ) );
148 }
149 }
150
151 public void addRole( String role )
152 {
153 update( getDelegate().withRoles(
154 Stream.concat( getDelegate().getRoles().stream(), Stream.of( role ) )
155 .collect( Collectors.toList() ) ) );
156 }
157
158 public void removeRole( String role )
159 {
160 update( getDelegate().withRoles(
161 getDelegate().getRoles().stream()
162 .filter( e -> !Objects.equals( e, role ) )
163 .collect( Collectors.toList() ) ) );
164 }
165
166 public String getTimezone()
167 {
168 return getDelegate().getTimezone();
169 }
170
171 public void setTimezone( String timezone )
172 {
173 if ( !Objects.equals( timezone, getDelegate().getTimezone() ) )
174 {
175 update( getDelegate().withTimezone( timezone ) );
176 }
177 }
178
179 @Nonnull
180 public Properties getProperties()
181 {
182 return new WrapperProperties( () -> getDelegate().getProperties(), this::setProperties );
183 }
184
185 public void setProperties( Properties properties )
186 {
187 Map<String, String> map = properties.entrySet().stream()
188 .collect( Collectors.toMap( e -> e.getKey().toString(), e -> e.getValue().toString() ) );
189 if ( !Objects.equals( map, getDelegate().getProperties() ) )
190 {
191 update( getDelegate().withProperties( map ) );
192 }
193 }
194
195 public void addProperty( String key, String value )
196 {
197 getProperties().put( key, value );
198 }
199
200 public InputLocation getLocation( Object key )
201 {
202 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation( key );
203 return loc != null ? new InputLocation( loc ) : null;
204 }
205
206 public void setLocation( Object key, InputLocation location )
207 {
208 update( org.apache.maven.api.model.Contributor.newBuilder( getDelegate(), true )
209 .location( key, location.toApiLocation() ).build() );
210 }
211
212 protected boolean replace( Object oldDelegate, Object newDelegate )
213 {
214 if ( super.replace( oldDelegate, newDelegate ) )
215 {
216 return true;
217 }
218 return false;
219 }
220
221 public static List<org.apache.maven.api.model.Contributor> contributorToApiV4( List<Contributor> list )
222 {
223 return list != null ? new WrapperList<>( list, Contributor::getDelegate, Contributor::new ) : null;
224 }
225
226 public static List<Contributor> contributorToApiV3( List<org.apache.maven.api.model.Contributor> list )
227 {
228 return list != null ? new WrapperList<>( list, Contributor::new, Contributor::getDelegate ) : null;
229 }
230
231
232
233
234
235
236 public String toString()
237 {
238 return "Contributor {name=" + getName() + ", email=" + getEmail() + "}";
239 }
240
241
242 }