Repository navigation
Expand file tree
/
Copy pathTemplateResponseDocumentFormFieldDropdown.java
More file actions
307 lines (274 loc) · 11.5 KB
/
Copy pathTemplateResponseDocumentFormFieldDropdown.java
File metadata and controls
307 lines (274 loc) · 11.5 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/*
* Dropbox Sign API
* Dropbox Sign v3 API
*
* The version of the OpenAPI document: 3.0.0
* Contact: apisupport@hellosign.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.dropbox.sign.model;
import com.dropbox.sign.ApiException;
import com.dropbox.sign.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** This class extends `TemplateResponseDocumentFormFieldBase` */
@JsonPropertyOrder({
TemplateResponseDocumentFormFieldDropdown.JSON_PROPERTY_TYPE,
TemplateResponseDocumentFormFieldDropdown.JSON_PROPERTY_GROUP,
TemplateResponseDocumentFormFieldDropdown.JSON_PROPERTY_OPTIONS
})
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
@JsonIgnoreProperties(
allowSetters = true, // allows the type to be set during deserialization
ignoreUnknown = true)
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "type",
visible = true)
public class TemplateResponseDocumentFormFieldDropdown
extends TemplateResponseDocumentFormFieldBase {
public static final String JSON_PROPERTY_TYPE = "type";
@javax.annotation.Nonnull private String type = "dropdown";
public static final String JSON_PROPERTY_GROUP = "group";
@javax.annotation.Nullable private String group;
public static final String JSON_PROPERTY_OPTIONS = "options";
@javax.annotation.Nullable private List<String> options = null;
public TemplateResponseDocumentFormFieldDropdown() {}
/**
* Attempt to instantiate and hydrate a new instance of this class
*
* @param jsonData String of JSON data representing target object
*/
public static TemplateResponseDocumentFormFieldDropdown init(String jsonData) throws Exception {
return new ObjectMapper()
.readValue(jsonData, TemplateResponseDocumentFormFieldDropdown.class);
}
public static TemplateResponseDocumentFormFieldDropdown init(HashMap data) throws Exception {
return new ObjectMapper()
.readValue(
new ObjectMapper().writeValueAsString(data),
TemplateResponseDocumentFormFieldDropdown.class);
}
public TemplateResponseDocumentFormFieldDropdown type(@javax.annotation.Nonnull String type) {
this.type = type;
return this;
}
/**
* The type of this form field. See [field types](/api/reference/constants/#field-types). * Text
* Field uses `TemplateResponseDocumentFormFieldText` * Dropdown Field uses
* `TemplateResponseDocumentFormFieldDropdown` * Hyperlink Field uses
* `TemplateResponseDocumentFormFieldHyperlink` * Checkbox Field uses
* `TemplateResponseDocumentFormFieldCheckbox` * Radio Field uses
* `TemplateResponseDocumentFormFieldRadio` * Signature Field uses
* `TemplateResponseDocumentFormFieldSignature` * Date Signed Field uses
* `TemplateResponseDocumentFormFieldDateSigned` * Initials Field uses
* `TemplateResponseDocumentFormFieldInitials`
*
* @return type
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getType() {
return type;
}
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setType(@javax.annotation.Nonnull String type) {
this.type = type;
}
public TemplateResponseDocumentFormFieldDropdown group(
@javax.annotation.Nullable String group) {
this.group = group;
return this;
}
/**
* The name of the group this field is in. If this field is not a group, this defaults to
* `null` except for Radio fields.
*
* @return group
*/
@javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_GROUP)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getGroup() {
return group;
}
@JsonProperty(JSON_PROPERTY_GROUP)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setGroup(@javax.annotation.Nullable String group) {
this.group = group;
}
public TemplateResponseDocumentFormFieldDropdown options(
@javax.annotation.Nullable List<String> options) {
this.options = options;
return this;
}
public TemplateResponseDocumentFormFieldDropdown addOptionsItem(String optionsItem) {
if (this.options == null) {
this.options = new ArrayList<>();
}
this.options.add(optionsItem);
return this;
}
/**
* The options available for this dropdown form field.
*
* @return options
*/
@javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_OPTIONS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getOptions() {
return options;
}
@JsonProperty(JSON_PROPERTY_OPTIONS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setOptions(@javax.annotation.Nullable List<String> options) {
this.options = options;
}
/** Return true if this TemplateResponseDocumentFormFieldDropdown object is equal to o. */
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TemplateResponseDocumentFormFieldDropdown templateResponseDocumentFormFieldDropdown =
(TemplateResponseDocumentFormFieldDropdown) o;
return Objects.equals(this.type, templateResponseDocumentFormFieldDropdown.type)
&& Objects.equals(this.group, templateResponseDocumentFormFieldDropdown.group)
&& Objects.equals(this.options, templateResponseDocumentFormFieldDropdown.options)
&& super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(type, group, options, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TemplateResponseDocumentFormFieldDropdown {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" group: ").append(toIndentedString(group)).append("\n");
sb.append(" options: ").append(toIndentedString(options)).append("\n");
sb.append("}");
return sb.toString();
}
public Map<String, Object> createFormData() throws ApiException {
Map<String, Object> map = new HashMap<>();
boolean fileTypeFound = false;
map.putAll(super.createFormData());
try {
if (type != null) {
if (isFileTypeOrListOfFiles(type)) {
fileTypeFound = true;
}
if (type.getClass().equals(java.io.File.class)
|| type.getClass().equals(Integer.class)
|| type.getClass().equals(String.class)
|| type.getClass().isEnum()) {
map.put("type", type);
} else if (isListOfFile(type)) {
for (int i = 0; i < getListSize(type); i++) {
map.put("type[" + i + "]", getFromList(type, i));
}
} else {
map.put("type", JSON.getDefault().getMapper().writeValueAsString(type));
}
}
if (group != null) {
if (isFileTypeOrListOfFiles(group)) {
fileTypeFound = true;
}
if (group.getClass().equals(java.io.File.class)
|| group.getClass().equals(Integer.class)
|| group.getClass().equals(String.class)
|| group.getClass().isEnum()) {
map.put("group", group);
} else if (isListOfFile(group)) {
for (int i = 0; i < getListSize(group); i++) {
map.put("group[" + i + "]", getFromList(group, i));
}
} else {
map.put("group", JSON.getDefault().getMapper().writeValueAsString(group));
}
}
if (options != null) {
if (isFileTypeOrListOfFiles(options)) {
fileTypeFound = true;
}
if (options.getClass().equals(java.io.File.class)
|| options.getClass().equals(Integer.class)
|| options.getClass().equals(String.class)
|| options.getClass().isEnum()) {
map.put("options", options);
} else if (isListOfFile(options)) {
for (int i = 0; i < getListSize(options); i++) {
map.put("options[" + i + "]", getFromList(options, i));
}
} else {
map.put("options", JSON.getDefault().getMapper().writeValueAsString(options));
}
}
} catch (Exception e) {
throw new ApiException(e);
}
return fileTypeFound ? map : new HashMap<>();
}
private boolean isFileTypeOrListOfFiles(Object obj) throws Exception {
return obj.getClass().equals(java.io.File.class) || isListOfFile(obj);
}
private boolean isListOfFile(Object obj) throws Exception {
return obj instanceof java.util.List
&& !isListEmpty(obj)
&& getFromList(obj, 0) instanceof java.io.File;
}
private boolean isListEmpty(Object obj) throws Exception {
return (boolean)
Class.forName(java.util.List.class.getName()).getMethod("isEmpty").invoke(obj);
}
private Object getFromList(Object obj, int index) throws Exception {
return Class.forName(java.util.List.class.getName())
.getMethod("get", int.class)
.invoke(obj, index);
}
private int getListSize(Object obj) throws Exception {
return (int) Class.forName(java.util.List.class.getName()).getMethod("size").invoke(obj);
}
/**
* Convert the given object to string with each line indented by 4 spaces (except the first
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
static {
// Initialize and register the discriminator mappings.
Map<String, Class<?>> mappings = new HashMap<>();
mappings.put(
"TemplateResponseDocumentFormFieldDropdown",
TemplateResponseDocumentFormFieldDropdown.class);
JSON.registerDiscriminator(
TemplateResponseDocumentFormFieldDropdown.class, "type", mappings);
}
}