@@ -39,8 +39,7 @@ public class JSON {
39
39
40
40
@ SuppressWarnings ("unchecked" )
41
41
public static GsonBuilder createGson () {
42
- GsonFireBuilder fireBuilder = new GsonFireBuilder ()
43
- ;
42
+ GsonFireBuilder fireBuilder = new GsonFireBuilder ();
44
43
GsonBuilder builder = fireBuilder .createGsonBuilder ();
45
44
return builder ;
46
45
}
@@ -54,10 +53,13 @@ private static String getDiscriminatorValue(JsonElement readElement, String disc
54
53
}
55
54
56
55
/**
57
- * Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
56
+ * Returns the Java class that implements the OpenAPI schema for the specified
57
+ * discriminator value.
58
58
*
59
- * @param classByDiscriminatorValue The map of discriminator values to Java classes.
60
- * @param discriminatorValue The value of the OpenAPI discriminator in the input data.
59
+ * @param classByDiscriminatorValue The map of discriminator values to Java
60
+ * classes.
61
+ * @param discriminatorValue The value of the OpenAPI discriminator in
62
+ * the input data.
61
63
* @return The Java class that implements the OpenAPI schema
62
64
*/
63
65
private static Class getClassByDiscriminator (Map classByDiscriminatorValue , String discriminatorValue ) {
@@ -70,12 +72,13 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
70
72
71
73
public JSON () {
72
74
gson = createGson ()
73
- .registerTypeAdapter (Date .class , dateTypeAdapter )
74
- .registerTypeAdapter (java .sql .Date .class , sqlDateTypeAdapter )
75
- .registerTypeAdapter (OffsetDateTime .class , offsetDateTimeTypeAdapter )
76
- .registerTypeAdapter (LocalDate .class , localDateTypeAdapter )
77
- .registerTypeAdapter (byte [].class , byteArrayAdapter )
78
- .create ();
75
+ .registerTypeAdapter (Date .class , dateTypeAdapter )
76
+ .registerTypeAdapter (java .sql .Date .class , sqlDateTypeAdapter )
77
+ .registerTypeAdapter (OffsetDateTime .class , offsetDateTimeTypeAdapter )
78
+ .registerTypeAdapter (LocalDate .class , localDateTypeAdapter )
79
+ .registerTypeAdapter (byte [].class , byteArrayAdapter )
80
+ .registerTypeAdapterFactory (new ConditionalNullable .ConditionalNullablePojoAdapterFactory ())
81
+ .create ();
79
82
}
80
83
81
84
/**
@@ -103,7 +106,8 @@ public JSON setGson(Gson gson) {
103
106
*
104
107
* @param lenientOnJson Set it to true to ignore some syntax errors
105
108
* @return JSON
106
- * @see <a href="https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html">https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html</a>
109
+ * @see <a href=
110
+ * "https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html">https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html</a>
107
111
*/
108
112
public JSON setLenientOnJson (boolean lenientOnJson ) {
109
113
isLenientOnJson = lenientOnJson ;
@@ -133,7 +137,8 @@ public <T> T deserialize(String body, Type returnType) {
133
137
try {
134
138
if (isLenientOnJson ) {
135
139
JsonReader jsonReader = new JsonReader (new StringReader (body ));
136
- // see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
140
+ // see
141
+ // https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
137
142
jsonReader .setLenient (true );
138
143
return gson .fromJson (jsonReader , returnType );
139
144
} else {
@@ -215,7 +220,7 @@ public OffsetDateTime read(JsonReader in) throws IOException {
215
220
default :
216
221
String date = in .nextString ();
217
222
if (date .endsWith ("+0000" )) {
218
- date = date .substring (0 , date .length ()- 5 ) + "Z" ;
223
+ date = date .substring (0 , date .length () - 5 ) + "Z" ;
219
224
}
220
225
return OffsetDateTime .parse (date , formatter );
221
226
}
@@ -282,7 +287,8 @@ public static class SqlDateTypeAdapter extends TypeAdapter<java.sql.Date> {
282
287
283
288
private DateFormat dateFormat ;
284
289
285
- public SqlDateTypeAdapter () {}
290
+ public SqlDateTypeAdapter () {
291
+ }
286
292
287
293
public SqlDateTypeAdapter (DateFormat dateFormat ) {
288
294
this .dateFormat = dateFormat ;
@@ -335,7 +341,8 @@ public static class DateTypeAdapter extends TypeAdapter<Date> {
335
341
336
342
private DateFormat dateFormat ;
337
343
338
- public DateTypeAdapter () {}
344
+ public DateTypeAdapter () {
345
+ }
339
346
340
347
public DateTypeAdapter (DateFormat dateFormat ) {
341
348
this .dateFormat = dateFormat ;
0 commit comments