Skip to content

Commit

Permalink
Remove redundant validation method
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 committed May 24, 2020
1 parent 4fb215c commit a4a235e
Showing 1 changed file with 4 additions and 10 deletions.
Expand Up @@ -29,6 +29,7 @@
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.$Gson$Preconditions;
import com.google.gson.internal.JavaVersion;
import com.google.gson.internal.PreJava9DateFormatProvider;
import com.google.gson.internal.bind.util.ISO8601Utils;
Expand Down Expand Up @@ -92,15 +93,15 @@ public final TypeAdapterFactory createDefaultsAdapterFactory() {
private final List<DateFormat> dateFormats = new ArrayList<DateFormat>();

private DefaultDateTypeAdapter(DateType<T> dateType, String datePattern) {
this.dateType = verifyDateType(dateType);
this.dateType = $Gson$Preconditions.checkNotNull(dateType);
dateFormats.add(new SimpleDateFormat(datePattern, Locale.US));
if (!Locale.getDefault().equals(Locale.US)) {
dateFormats.add(new SimpleDateFormat(datePattern));
}
}

private DefaultDateTypeAdapter(DateType<T> dateType, int style) {
this.dateType = verifyDateType(dateType);
this.dateType = $Gson$Preconditions.checkNotNull(dateType);
dateFormats.add(DateFormat.getDateInstance(style, Locale.US));
if (!Locale.getDefault().equals(Locale.US)) {
dateFormats.add(DateFormat.getDateInstance(style));
Expand All @@ -111,7 +112,7 @@ private DefaultDateTypeAdapter(DateType<T> dateType, int style) {
}

private DefaultDateTypeAdapter(DateType<T> dateType, int dateStyle, int timeStyle) {
this.dateType = verifyDateType(dateType);
this.dateType = $Gson$Preconditions.checkNotNull(dateType);
dateFormats.add(DateFormat.getDateTimeInstance(dateStyle, timeStyle, Locale.US));
if (!Locale.getDefault().equals(Locale.US)) {
dateFormats.add(DateFormat.getDateTimeInstance(dateStyle, timeStyle));
Expand All @@ -121,13 +122,6 @@ private DefaultDateTypeAdapter(DateType<T> dateType, int dateStyle, int timeStyl
}
}

private static <T extends Date> DateType<T> verifyDateType(DateType<T> dateType) {
if (dateType == null) {
throw new NullPointerException("dateType == null");
}
return dateType;
}

// These methods need to be synchronized since JDK DateFormat classes are not thread-safe
// See issue 162
@Override
Expand Down

0 comments on commit a4a235e

Please sign in to comment.