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.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          this(org.apache.maven.api.model.Contributor.newInstance());
28      }
29  
30      public Contributor(org.apache.maven.api.model.Contributor delegate) {
31          this(delegate, null);
32      }
33  
34      public Contributor(org.apache.maven.api.model.Contributor delegate, BaseObject parent) {
35          super(delegate, parent);
36      }
37  
38      public Contributor clone(){
39          return new Contributor(getDelegate());
40      }
41  
42      public org.apache.maven.api.model.Contributor getDelegate() {
43          return (org.apache.maven.api.model.Contributor) 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 Contributor)) {
52              return false;
53          }
54          Contributor that = (Contributor) 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 String getName() {
64          return getDelegate().getName();
65      }
66  
67      public void setName(String name) {
68          if (!Objects.equals(name, getName())) {
69              update(getDelegate().withName(name));
70          }
71      }
72  
73      public String getEmail() {
74          return getDelegate().getEmail();
75      }
76  
77      public void setEmail(String email) {
78          if (!Objects.equals(email, getEmail())) {
79              update(getDelegate().withEmail(email));
80          }
81      }
82  
83      public String getUrl() {
84          return getDelegate().getUrl();
85      }
86  
87      public void setUrl(String url) {
88          if (!Objects.equals(url, getUrl())) {
89              update(getDelegate().withUrl(url));
90          }
91      }
92  
93      public String getOrganization() {
94          return getDelegate().getOrganization();
95      }
96  
97      public void setOrganization(String organization) {
98          if (!Objects.equals(organization, getOrganization())) {
99              update(getDelegate().withOrganization(organization));
100         }
101     }
102 
103     public String getOrganizationUrl() {
104         return getDelegate().getOrganizationUrl();
105     }
106 
107     public void setOrganizationUrl(String organizationUrl) {
108         if (!Objects.equals(organizationUrl, getOrganizationUrl())) {
109             update(getDelegate().withOrganizationUrl(organizationUrl));
110         }
111     }
112 
113     @Nonnull
114     public List<String> getRoles() {
115         return new WrapperList<String, String>(() -> getDelegate().getRoles(), this::setRoles, s -> s, s -> s);
116     }
117 
118     public void setRoles(List<String> roles) {
119         if (!Objects.equals(roles, getRoles())) {
120             update(getDelegate().withRoles(roles));
121         }
122     }
123 
124     public void addRole(String role) {
125         update(getDelegate().withRoles(
126                Stream.concat(getDelegate().getRoles().stream(), Stream.of(role))
127                         .collect(Collectors.toList())));
128     }
129 
130     public void removeRole(String role) {
131         update(getDelegate().withRoles(
132                getDelegate().getRoles().stream()
133                         .filter(e -> !Objects.equals(e, role))
134                         .collect(Collectors.toList())));
135     }
136 
137     public String getTimezone() {
138         return getDelegate().getTimezone();
139     }
140 
141     public void setTimezone(String timezone) {
142         if (!Objects.equals(timezone, getTimezone())) {
143             update(getDelegate().withTimezone(timezone));
144         }
145     }
146 
147     @Nonnull
148     public Properties getProperties() {
149         return new WrapperProperties(() -> getDelegate().getProperties(), this::setProperties);
150     }
151 
152     public void setProperties(Properties properties) {
153         Map<String, String> map = properties.entrySet().stream()
154                 .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
155         if (!Objects.equals(map, getDelegate().getProperties())) {
156             update(getDelegate().withProperties(map));
157         }
158     }
159 
160     public void addProperty(String key, String value) {
161         getProperties().put(key, value);
162     }
163 
164     public InputLocation getLocation(Object key) {
165         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
166         return loc != null ? new InputLocation(loc) : null;
167     }
168 
169     public void setLocation(Object key, InputLocation location) {
170         update(org.apache.maven.api.model.Contributor.newBuilder(getDelegate(), true)
171                         .location(key, location.toApiLocation()).build());
172     }
173 
174     protected boolean replace(Object oldDelegate, Object newDelegate) {
175         if (super.replace(oldDelegate, newDelegate)) {
176             return true;
177         }
178         return false;
179     }
180 
181     public static List<org.apache.maven.api.model.Contributor> contributorToApiV4(List<Contributor> list) {
182         return list != null ? new WrapperList<>(list, Contributor::getDelegate, Contributor::new) : null;
183     }
184 
185     public static List<Contributor> contributorToApiV3(List<org.apache.maven.api.model.Contributor> list) {
186         return list != null ? new WrapperList<>(list, Contributor::new, Contributor::getDelegate) : null;
187     }
188 
189 
190             
191     /**
192      * @see java.lang.Object#toString()
193      */
194     public String toString()
195     {
196         return "Contributor {name=" + getName() + ", email=" + getEmail() + "}";
197     }
198             
199           
200 }