forked from sngular/scs-multiapi-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGadgetDTO.java
More file actions
261 lines (222 loc) · 7.04 KB
/
Copy pathGadgetDTO.java
File metadata and controls
261 lines (222 loc) · 7.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
package com.sngular.multifileplugin.openapi31completeness.model;
import java.util.Objects;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import java.util.Map;
import java.util.HashMap;
@JsonDeserialize(builder = GadgetDTO.GadgetDTOBuilder.class)
public class GadgetDTO {
@JsonProperty(value ="status")
private Status status;
public enum Status {
ACTIVE("ACTIVE"),
RETIRED("RETIRED");
private String value;
Status(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
}
@JsonProperty(value ="legacyId")
private String legacyId;
@JsonProperty(value ="payload")
private MultipartFile payload;
@JsonProperty(value ="nothing")
private Object nothing;
@JsonProperty(value ="id")
private String id;
@JsonProperty(value ="metadata")
private Map<String, String> metadata;
@JsonProperty(value ="coords")
private List<BigDecimal> coords;
@JsonProperty(value ="owner")
private PersonDTO owner;
@JsonProperty(value ="serial")
private String serial;
private GadgetDTO(GadgetDTOBuilder builder) {
this.status = builder.status;
this.legacyId = builder.legacyId;
this.payload = builder.payload;
this.nothing = builder.nothing;
this.id = builder.id;
this.metadata = builder.metadata;
this.coords = builder.coords;
this.owner = builder.owner;
this.serial = builder.serial;
}
public static GadgetDTO.GadgetDTOBuilder builder() {
return new GadgetDTO.GadgetDTOBuilder();
}
@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "")
public static class GadgetDTOBuilder {
private Status status;
private String legacyId;
private MultipartFile payload;
private Object nothing;
private String id;
private Map<String, String> metadata = new HashMap<String, String>();
private List<BigDecimal> coords = new ArrayList<BigDecimal>();
private PersonDTO owner;
private String serial;
public GadgetDTO.GadgetDTOBuilder status(Status status) {
this.status = status;
return this;
}
public GadgetDTO.GadgetDTOBuilder legacyId(String legacyId) {
this.legacyId = legacyId;
return this;
}
public GadgetDTO.GadgetDTOBuilder payload(MultipartFile payload) {
this.payload = payload;
return this;
}
public GadgetDTO.GadgetDTOBuilder nothing(Object nothing) {
this.nothing = nothing;
return this;
}
public GadgetDTO.GadgetDTOBuilder id(String id) {
this.id = id;
return this;
}
public GadgetDTO.GadgetDTOBuilder metadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}
public GadgetDTO.GadgetDTOBuilder metadataValue(String key, String value) {
this.metadata.put(key, value);
return this;
}
public GadgetDTO.GadgetDTOBuilder coords(List<BigDecimal> coords) {
if (!coords.isEmpty()) {
this.coords.addAll(coords);
}
return this;
}
public GadgetDTO.GadgetDTOBuilder coord(BigDecimal coord) {
if (Objects.nonNull(coord)) {
this.coords.add(coord);
}
return this;
}
public GadgetDTO.GadgetDTOBuilder owner(PersonDTO owner) {
this.owner = owner;
return this;
}
public GadgetDTO.GadgetDTOBuilder serial(String serial) {
this.serial = serial;
return this;
}
public GadgetDTO build() {
GadgetDTO gadgetDTO = new GadgetDTO(this);
return gadgetDTO;
}
}
@Schema(name = "status", required = false, description = "Lifecycle status of the gadget")
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
@Schema(name = "legacyId", required = false, deprecated = true)
public String getLegacyId() {
return legacyId;
}
public void setLegacyId(String legacyId) {
this.legacyId = legacyId;
}
@Schema(name = "payload", required = false)
public MultipartFile getPayload() {
return payload;
}
public void setPayload(MultipartFile payload) {
this.payload = payload;
}
@Schema(name = "nothing", required = false)
public Object getNothing() {
return nothing;
}
public void setNothing(Object nothing) {
this.nothing = nothing;
}
@Schema(name = "id", required = false, description = "The unique gadget identifier", example = "gadget-001")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Schema(name = "metadata", required = false)
public Map<String, String> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
}
@Schema(name = "coords", required = false)
public List<BigDecimal> getCoords() {
return coords;
}
public void setCoords(List<BigDecimal> coords) {
this.coords = coords;
}
@Schema(name = "owner", required = false)
public PersonDTO getOwner() {
return owner;
}
public void setOwner(PersonDTO owner) {
this.owner = owner;
}
@Schema(name = "serial", required = false, example = "SN-12345")
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GadgetDTO gadgetDTO = (GadgetDTO) o;
return Objects.equals(this.status, gadgetDTO.status) && Objects.equals(this.legacyId, gadgetDTO.legacyId) && Objects.equals(this.payload, gadgetDTO.payload) && Objects.equals(this.nothing, gadgetDTO.nothing) && Objects.equals(this.id, gadgetDTO.id) && Objects.equals(this.metadata, gadgetDTO.metadata) && Objects.equals(this.coords, gadgetDTO.coords) && Objects.equals(this.owner, gadgetDTO.owner) && Objects.equals(this.serial, gadgetDTO.serial);
}
@Override
public int hashCode() {
return Objects.hash(status, legacyId, payload, nothing, id, metadata, coords, owner, serial);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("GadgetDTO{");
sb.append(" status:").append(status).append(",");
sb.append(" legacyId:").append(legacyId).append(",");
sb.append(" payload:").append(payload).append(",");
sb.append(" nothing:").append(nothing).append(",");
sb.append(" id:").append(id).append(",");
sb.append(" metadata:").append(metadata).append(",");
sb.append(" coords:").append(coords).append(",");
sb.append(" owner:").append(owner).append(",");
sb.append(" serial:").append(serial);
sb.append("}");
return sb.toString();
}
}