diff --git a/gson/src/main/java/com/google/gson/ExclusionStrategy.java b/gson/src/main/java/com/google/gson/ExclusionStrategy.java index 557eddb2..516666ee 100644 --- a/gson/src/main/java/com/google/gson/ExclusionStrategy.java +++ b/gson/src/main/java/com/google/gson/ExclusionStrategy.java @@ -93,12 +93,16 @@ package com.google.gson; public interface ExclusionStrategy { /** + * Decides if a field should be skipped during serialization or deserialization. + * * @param f the field object that is under test * @return true if the field should be ignored; otherwise false */ public boolean shouldSkipField(FieldAttributes f); /** + * Decides if a class should be serialized or deserialized + * * @param clazz the class object that is under test * @return true if the class should be ignored; otherwise false */ diff --git a/gson/src/main/java/com/google/gson/FieldAttributes.java b/gson/src/main/java/com/google/gson/FieldAttributes.java index 4b9e16ab..5ce710bd 100644 --- a/gson/src/main/java/com/google/gson/FieldAttributes.java +++ b/gson/src/main/java/com/google/gson/FieldAttributes.java @@ -46,6 +46,8 @@ public final class FieldAttributes { } /** + * Gets the declaring Class that contains this field + * * @return the declaring class that contains this field */ public Class getDeclaringClass() { @@ -53,6 +55,8 @@ public final class FieldAttributes { } /** + * Gets the name of the field + * * @return the name of the field */ public String getName() { diff --git a/gson/src/main/java/com/google/gson/JsonDeserializer.java b/gson/src/main/java/com/google/gson/JsonDeserializer.java index ca797eee..94f871ae 100644 --- a/gson/src/main/java/com/google/gson/JsonDeserializer.java +++ b/gson/src/main/java/com/google/gson/JsonDeserializer.java @@ -89,7 +89,7 @@ public interface JsonDeserializer { * @param json The Json data being deserialized * @param typeOfT The type of the Object to deserialize to * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T} - * @throws JsonParseException if json is not in the expected format of {@code typeofT} + * @throws JsonParseException if json is not in the expected format of {@code typeOfT} */ public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException; diff --git a/gson/src/main/java/com/google/gson/annotations/SerializedName.java b/gson/src/main/java/com/google/gson/annotations/SerializedName.java index e50ad55c..4ec3a4bb 100644 --- a/gson/src/main/java/com/google/gson/annotations/SerializedName.java +++ b/gson/src/main/java/com/google/gson/annotations/SerializedName.java @@ -83,10 +83,14 @@ import java.lang.annotation.Target; public @interface SerializedName { /** + * The desired name of the field when it is serialized or deserialized. + * * @return the desired name of the field when it is serialized or deserialized */ String value(); /** + * The alternative names of the field when it is deserialized + * * @return the alternative names of the field when it is deserialized */ String[] alternate() default {}; diff --git a/gson/src/main/java/com/google/gson/internal/JavaVersion.java b/gson/src/main/java/com/google/gson/internal/JavaVersion.java index fab1b7c2..df8e9a49 100644 --- a/gson/src/main/java/com/google/gson/internal/JavaVersion.java +++ b/gson/src/main/java/com/google/gson/internal/JavaVersion.java @@ -75,6 +75,8 @@ public final class JavaVersion { } /** + * Gets the major Java version + * * @return the major Java version, i.e. '8' for Java 1.8, '9' for Java 9 etc. */ public static int getMajorJavaVersion() { @@ -82,6 +84,8 @@ public final class JavaVersion { } /** + * Gets a boolean value depending if the application is running on Java 9 or later + * * @return {@code true} if the application is running on Java 9 or later; and {@code false} otherwise. */ public static boolean isJava9OrLater() { diff --git a/gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java b/gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java index 89e6b9a9..dc31b3ad 100644 --- a/gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java +++ b/gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java @@ -98,6 +98,7 @@ public class ReflectionAccessFilterHelper { } }; } catch (NoSuchMethodException ignored) { + // OK: will assume everything is accessible } } diff --git a/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java b/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java index fae6f802..90990513 100644 --- a/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java +++ b/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java @@ -64,6 +64,7 @@ public abstract class UnsafeAllocator { } }; } catch (Exception ignored) { + // OK: try the next way } // try dalvikvm, post-gingerbread @@ -88,6 +89,7 @@ public abstract class UnsafeAllocator { } }; } catch (Exception ignored) { + // OK: try the next way } // try dalvikvm, pre-gingerbread @@ -108,6 +110,7 @@ public abstract class UnsafeAllocator { } }; } catch (Exception ignored) { + // OK: try the next way } // give up diff --git a/gson/src/main/java/com/google/gson/internal/bind/DateTypeAdapter.java b/gson/src/main/java/com/google/gson/internal/bind/DateTypeAdapter.java index decd3c5c..36b5f55e 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/DateTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/internal/bind/DateTypeAdapter.java @@ -81,7 +81,9 @@ public final class DateTypeAdapter extends TypeAdapter { for (DateFormat dateFormat : dateFormats) { try { return dateFormat.parse(s); - } catch (ParseException ignored) {} + } catch (ParseException ignored) { + // OK: try the next format + } } } try { diff --git a/gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java b/gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java index 9e578bf4..6a23f330 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java @@ -154,7 +154,9 @@ public final class DefaultDateTypeAdapter extends TypeAdapter for (DateFormat dateFormat : dateFormats) { try { return dateFormat.parse(s); - } catch (ParseException ignored) {} + } catch (ParseException ignored) { + // OK: try the next format + } } } diff --git a/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java b/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java index e6a45302..3705ceb0 100644 --- a/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java +++ b/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java @@ -40,6 +40,7 @@ import java.io.Reader; import java.io.StringWriter; import java.lang.reflect.Type; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -137,7 +138,7 @@ public final class ParseBenchmark { ZipFile zipFile = new ZipFile(getResourceFile("/ParseBenchmarkData.zip")); try { ZipEntry zipEntry = zipFile.getEntry(fileName); - Reader reader = new InputStreamReader(zipFile.getInputStream(zipEntry)); + Reader reader = new InputStreamReader(zipFile.getInputStream(zipEntry), StandardCharsets.UTF_8); char[] buffer = new char[8192]; StringWriter writer = new StringWriter(); int count;