-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathUrlImage.java
More file actions
275 lines (222 loc) · 7.62 KB
/
UrlImage.java
File metadata and controls
275 lines (222 loc) · 7.62 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
/*
Copyright 2020 Twitter, Inc.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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.twitter.clientlib.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.net.URL;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.twitter.clientlib.JSON;
/**
* Represent the information for the URL image.
*/
@ApiModel(description = "Represent the information for the URL image.")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class UrlImage {
public static final String SERIALIZED_NAME_HEIGHT = "height";
@SerializedName(SERIALIZED_NAME_HEIGHT)
private Integer height;
public static final String SERIALIZED_NAME_URL = "url";
@SerializedName(SERIALIZED_NAME_URL)
private URL url;
public static final String SERIALIZED_NAME_WIDTH = "width";
@SerializedName(SERIALIZED_NAME_WIDTH)
private Integer width;
public UrlImage() {
}
public UrlImage height(Integer height) {
this.height = height;
return this;
}
/**
* The height of the media in pixels.
* minimum: 0
* @return height
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "The height of the media in pixels.")
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public UrlImage url(URL url) {
this.url = url;
return this;
}
/**
* A validly formatted URL.
* @return url
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "https://developer.twitter.com/en/docs/twitter-api", value = "A validly formatted URL.")
public URL getUrl() {
return url;
}
public void setUrl(URL url) {
this.url = url;
}
public UrlImage width(Integer width) {
this.width = width;
return this;
}
/**
* The width of the media in pixels.
* minimum: 0
* @return width
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "The width of the media in pixels.")
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UrlImage urlImage = (UrlImage) o;
return Objects.equals(this.height, urlImage.height) &&
Objects.equals(this.url, urlImage.url) &&
Objects.equals(this.width, urlImage.width);
}
@Override
public int hashCode() {
return Objects.hash(height, url, width);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UrlImage {\n");
sb.append(" height: ").append(toIndentedString(height)).append("\n");
sb.append(" url: ").append(toIndentedString(url)).append("\n");
sb.append(" width: ").append(toIndentedString(width)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* 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 ");
}
public static HashSet<String> openapiFields;
public static HashSet<String> openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet<String>();
openapiFields.add("height");
openapiFields.add("url");
openapiFields.add("width");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>();
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to UrlImage
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
// if (jsonObj == null) {
// if (UrlImage.openapiRequiredFields.isEmpty()) {
// return;
// } else { // has required fields
// throw new IllegalArgumentException(String.format("The required field(s) %s in UrlImage is not found in the empty JSON string", UrlImage.openapiRequiredFields.toString()));
// }
// }
if (jsonObj.get("url") != null && !jsonObj.get("url").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (!UrlImage.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UrlImage' and its subtypes
}
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter<UrlImage> thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UrlImage.class));
return (TypeAdapter<T>) new TypeAdapter<UrlImage>() {
@Override
public void write(JsonWriter out, UrlImage value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public UrlImage read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of UrlImage given an JSON string
*
* @param jsonString JSON string
* @return An instance of UrlImage
* @throws IOException if the JSON string is invalid with respect to UrlImage
*/
public static UrlImage fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UrlImage.class);
}
/**
* Convert an instance of UrlImage to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}