Skip to content
Snippets Groups Projects
Commit 6ad1bda8 authored by Mamadu-lamarana Bah's avatar Mamadu-lamarana Bah :speech_balloon:
Browse files

transformation d'un switch en un if-else pour améliorer la lisibilité

parent d363eccc
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ package com.google.gson.typeadapters; ...@@ -19,6 +19,7 @@ package com.google.gson.typeadapters;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
...@@ -45,15 +46,15 @@ public final class UtcDateTypeAdapter extends TypeAdapter<Date> { ...@@ -45,15 +46,15 @@ public final class UtcDateTypeAdapter extends TypeAdapter<Date> {
@Override @Override
public Date read(JsonReader in) throws IOException { public Date read(JsonReader in) throws IOException {
try { try {
switch (in.peek()) { if(in.peek() == JsonToken.NULL) {
case NULL: in.nextNull();
in.nextNull(); return null;
return null; }
default: else {
String date = in.nextString(); String date = in.nextString();
// Instead of using iso8601Format.parse(value), we use Jackson's date parsing // Instead of using iso8601Format.parse(value), we use Jackson's date parsing
// This is because Android doesn't support XXX because it is JDK 1.6 // This is because Android doesn't support XXX because it is JDK 1.6
return parse(date, new ParsePosition(0)); return parse(date, new ParsePosition(0));
} }
} catch (ParseException e) { } catch (ParseException e) {
throw new JsonParseException(e); throw new JsonParseException(e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment