View Javadoc
1   /*
2    * Copyright 2019-2020 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.groupman.model;
18  
19  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
20  import com.fasterxml.jackson.annotation.JsonProperty;
21  import io.swagger.v3.oas.annotations.media.Schema;
22  import io.swagger.v3.oas.annotations.media.Schema.AccessMode;
23  import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
24  import jakarta.validation.Valid;
25  import java.io.Serial;
26  import java.io.Serializable;
27  import java.time.OffsetDateTime;
28  import java.util.ArrayList;
29  import java.util.List;
30  import jakarta.validation.constraints.NotNull;
31  import jakarta.validation.constraints.Size;
32  import lombok.Builder;
33  import lombok.EqualsAndHashCode;
34  import lombok.NoArgsConstructor;
35  import lombok.ToString;
36  
37  /**
38   * The group.
39   *
40   * @author Christian Bremer
41   */
42  @Schema(description = "The group.")
43  @JsonIgnoreProperties(ignoreUnknown = true)
44  @EqualsAndHashCode
45  @ToString
46  @NoArgsConstructor
47  @Valid
48  public class Group implements Serializable {
49  
50    @Serial
51    private static final long serialVersionUID = 1L;
52  
53    @JsonProperty("id")
54    private String id = null;
55  
56    @JsonProperty("version")
57    private Long version = null;
58  
59    @JsonProperty("createdBy")
60    private String createdBy = null;
61  
62    @JsonProperty("createdAt")
63    private OffsetDateTime createdAt = null;
64  
65    @JsonProperty("modifiedAt")
66    private OffsetDateTime modifiedAt = null;
67  
68    @JsonProperty("source")
69    private Source source = null;
70  
71    @JsonProperty(value = "name", required = true)
72    private String name = null;
73  
74    @JsonProperty("description")
75    private String description = null;
76  
77    @JsonProperty("members")
78    private List<String> members = null;
79  
80    @JsonProperty("owners")
81    private List<String> owners = null;
82  
83    /**
84     * Instantiates a new group.
85     *
86     * @param id the id
87     * @param version the version
88     * @param createdBy the created by
89     * @param createdAt the created at
90     * @param modifiedAt the modified at
91     * @param source the source
92     * @param name the name
93     * @param description the description
94     * @param members the members
95     * @param owners the owners
96     */
97    @Builder(toBuilder = true)
98    public Group(String id, Long version, String createdBy, OffsetDateTime createdAt,
99        OffsetDateTime modifiedAt, Source source, String name, String description,
100       List<String> members, List<String> owners) {
101     this.id = id;
102     this.version = version;
103     this.createdBy = createdBy;
104     this.createdAt = createdAt;
105     this.modifiedAt = modifiedAt;
106     this.source = source;
107     this.name = name;
108     this.description = description;
109     this.members = members;
110     this.owners = owners;
111   }
112 
113   /**
114    * Gets id.
115    *
116    * @return the id
117    */
118   @Schema(
119       description = "Unique identifier of the group.",
120       accessMode = AccessMode.READ_ONLY,
121       maxLength = 255)
122   @Size(max = 255)
123   public String getId() {
124     return id;
125   }
126 
127   /**
128    * Sets id.
129    *
130    * @param id the id
131    */
132   public void setId(String id) {
133     this.id = id;
134   }
135 
136   /**
137    * Gets version.
138    *
139    * @return the version
140    */
141   @Schema(description = "The database version number.", accessMode = AccessMode.READ_ONLY)
142   public Long getVersion() {
143     return version;
144   }
145 
146   /**
147    * Sets version.
148    *
149    * @param version the version
150    */
151   public void setVersion(Long version) {
152     this.version = version;
153   }
154 
155   /**
156    * Gets created by.
157    *
158    * @return the created by
159    */
160   @Schema(description = "The user who created the group.", maxLength = 255)
161   @Size(max = 255)
162   public String getCreatedBy() {
163     return createdBy;
164   }
165 
166   /**
167    * Sets created by.
168    *
169    * @param createdBy the created by
170    */
171   public void setCreatedBy(String createdBy) {
172     this.createdBy = createdBy;
173   }
174 
175   /**
176    * Gets created at.
177    *
178    * @return the created at
179    */
180   @Schema(description = "The creation time.", accessMode = AccessMode.READ_ONLY)
181   public OffsetDateTime getCreatedAt() {
182     return createdAt;
183   }
184 
185   /**
186    * Sets created at.
187    *
188    * @param createdAt the created at
189    */
190   public void setCreatedAt(OffsetDateTime createdAt) {
191     this.createdAt = createdAt;
192   }
193 
194   /**
195    * Gets modified at.
196    *
197    * @return the modified at
198    */
199   @Schema(description = "The last modification time.", accessMode = AccessMode.READ_ONLY)
200   public OffsetDateTime getModifiedAt() {
201     return modifiedAt;
202   }
203 
204   /**
205    * Sets modified at.
206    *
207    * @param modifiedAt the modified at
208    */
209   public void setModifiedAt(OffsetDateTime modifiedAt) {
210     this.modifiedAt = modifiedAt;
211   }
212 
213   /**
214    * Gets source.
215    *
216    * @return the source
217    */
218   @Schema(description = "The source.", accessMode = AccessMode.READ_ONLY)
219   public Source getSource() {
220     return source;
221   }
222 
223   /**
224    * Sets source.
225    *
226    * @param source the source
227    */
228   public void setSource(Source source) {
229     this.source = source;
230   }
231 
232   /**
233    * Gets name.
234    *
235    * @return the name
236    */
237   @Schema(
238       description = "The name of the group.",
239       requiredMode = RequiredMode.REQUIRED,
240       minLength = 3,
241       maxLength = 75)
242   @NotNull
243   @Size(min = 3, max = 75)
244   public String getName() {
245     return name;
246   }
247 
248   /**
249    * Sets name.
250    *
251    * @param name the name
252    */
253   public void setName(String name) {
254     this.name = name;
255   }
256 
257   /**
258    * Gets description.
259    *
260    * @return the description
261    */
262   @Schema(description = "The description of the group.", maxLength = 255)
263   @Size(max = 255)
264   public String getDescription() {
265     return description;
266   }
267 
268   /**
269    * Sets description.
270    *
271    * @param description the description
272    */
273   public void setDescription(String description) {
274     this.description = description;
275   }
276 
277   /**
278    * Gets members.
279    *
280    * @return the members
281    */
282   @Schema(description = "The members of the group.")
283   public List<String> getMembers() {
284     if (members == null) {
285       members = new ArrayList<>();
286     }
287     return members;
288   }
289 
290   /**
291    * Sets members.
292    *
293    * @param members the members
294    */
295   public void setMembers(List<String> members) {
296     this.members = members;
297   }
298 
299   /**
300    * Gets owners.
301    *
302    * @return the owners
303    */
304   @Schema(description = "The owners of the group.")
305   public List<String> getOwners() {
306     if (owners == null) {
307       owners = new ArrayList<>();
308     }
309     return owners;
310   }
311 
312   /**
313    * Sets owners.
314    *
315    * @param owners the owners
316    */
317   public void setOwners(List<String> owners) {
318     this.owners = owners;
319   }
320 
321 }
322