@@ -39,8 +39,7 @@ public class JSON {
3939
4040 @ SuppressWarnings ("unchecked" )
4141 public static GsonBuilder createGson () {
42- GsonFireBuilder fireBuilder = new GsonFireBuilder ()
43- ;
42+ GsonFireBuilder fireBuilder = new GsonFireBuilder ();
4443 GsonBuilder builder = fireBuilder .createGsonBuilder ();
4544 return builder ;
4645 }
@@ -54,10 +53,13 @@ private static String getDiscriminatorValue(JsonElement readElement, String disc
5453 }
5554
5655 /**
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.
5858 *
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.
6163 * @return The Java class that implements the OpenAPI schema
6264 */
6365 private static Class getClassByDiscriminator (Map classByDiscriminatorValue , String discriminatorValue ) {
@@ -70,12 +72,13 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
7072
7173 public JSON () {
7274 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 ();
7982 }
8083
8184 /**
@@ -103,7 +106,8 @@ public JSON setGson(Gson gson) {
103106 *
104107 * @param lenientOnJson Set it to true to ignore some syntax errors
105108 * @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>
107111 */
108112 public JSON setLenientOnJson (boolean lenientOnJson ) {
109113 isLenientOnJson = lenientOnJson ;
@@ -133,7 +137,8 @@ public <T> T deserialize(String body, Type returnType) {
133137 try {
134138 if (isLenientOnJson ) {
135139 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
137142 jsonReader .setLenient (true );
138143 return gson .fromJson (jsonReader , returnType );
139144 } else {
@@ -215,7 +220,7 @@ public OffsetDateTime read(JsonReader in) throws IOException {
215220 default :
216221 String date = in .nextString ();
217222 if (date .endsWith ("+0000" )) {
218- date = date .substring (0 , date .length ()- 5 ) + "Z" ;
223+ date = date .substring (0 , date .length () - 5 ) + "Z" ;
219224 }
220225 return OffsetDateTime .parse (date , formatter );
221226 }
@@ -282,7 +287,8 @@ public static class SqlDateTypeAdapter extends TypeAdapter<java.sql.Date> {
282287
283288 private DateFormat dateFormat ;
284289
285- public SqlDateTypeAdapter () {}
290+ public SqlDateTypeAdapter () {
291+ }
286292
287293 public SqlDateTypeAdapter (DateFormat dateFormat ) {
288294 this .dateFormat = dateFormat ;
@@ -335,7 +341,8 @@ public static class DateTypeAdapter extends TypeAdapter<Date> {
335341
336342 private DateFormat dateFormat ;
337343
338- public DateTypeAdapter () {}
344+ public DateTypeAdapter () {
345+ }
339346
340347 public DateTypeAdapter (DateFormat dateFormat ) {
341348 this .dateFormat = dateFormat ;
0 commit comments