From b75e1bbc7915f409ba0254fcc92c71ed6798e69b Mon Sep 17 00:00:00 2001 From: Lorenz Nickel Date: Sun, 3 Mar 2019 20:18:06 +0100 Subject: [PATCH] Code cleanup (Removed spaces) (#1474) * Removed double spaces in comments * Unified comments * Removed space * Removed spaces in code --- .../com/google/gson/ExclusionStrategy.java | 2 +- .../com/google/gson/FieldNamingStrategy.java | 4 ++-- gson/src/main/java/com/google/gson/Gson.java | 2 +- .../com/google/gson/JsonParseException.java | 6 +++--- .../com/google/gson/JsonStreamParser.java | 2 +- .../google/gson/LongSerializationPolicy.java | 4 ++-- .../gson/annotations/SerializedName.java | 2 +- .../com/google/gson/annotations/Until.java | 2 +- .../functional/CustomDeserializerTest.java | 2 +- .../functional/DefaultTypeAdaptersTest.java | 8 ++++---- .../gson/functional/InheritanceTest.java | 4 ++-- .../gson/functional/InstanceCreatorTest.java | 2 +- .../functional/NullObjectAndFieldTest.java | 4 ++-- .../functional/ParameterizedTypesTest.java | 10 +++++----- .../gson/functional/VersioningTest.java | 2 +- .../UnsafeAllocatorInstantiationTest.java | 4 ++-- .../bind/RecursiveTypesResolveTest.java | 20 ++++++++++--------- .../google/gson/metrics/PerformanceTest.java | 20 +++++++++---------- 18 files changed, 51 insertions(+), 49 deletions(-) diff --git a/gson/src/main/java/com/google/gson/ExclusionStrategy.java b/gson/src/main/java/com/google/gson/ExclusionStrategy.java index 6a3f43fb..ea452681 100644 --- a/gson/src/main/java/com/google/gson/ExclusionStrategy.java +++ b/gson/src/main/java/com/google/gson/ExclusionStrategy.java @@ -20,7 +20,7 @@ package com.google.gson; * A strategy (or policy) definition that is used to decide whether or not a field or top-level * class should be serialized or deserialized as part of the JSON output/input. For serialization, * if the {@link #shouldSkipClass(Class)} method returns true then that class or field type - * will not be part of the JSON output. For deserialization, if {@link #shouldSkipClass(Class)} + * will not be part of the JSON output. For deserialization, if {@link #shouldSkipClass(Class)} * returns true, then it will not be set as part of the Java object structure. * *

The following are a few examples that shows how you can use this exclusion mechanism. diff --git a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java index 9be453ad..f2f7c489 100644 --- a/gson/src/main/java/com/google/gson/FieldNamingStrategy.java +++ b/gson/src/main/java/com/google/gson/FieldNamingStrategy.java @@ -19,9 +19,9 @@ package com.google.gson; import java.lang.reflect.Field; /** - * A mechanism for providing custom field naming in Gson. This allows the client code to translate + * A mechanism for providing custom field naming in Gson. This allows the client code to translate * field names into a particular convention that is not supported as a normal Java field - * declaration rules. For example, Java does not support "-" characters in a field name. + * declaration rules. For example, Java does not support "-" characters in a field name. * * @author Inderjeet Singh * @author Joel Leitch diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index ba677e26..0cb171c7 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -80,7 +80,7 @@ import com.google.gson.stream.MalformedJsonException; * *

If the object that your are serializing/deserializing is a {@code ParameterizedType} * (i.e. contains at least one type parameter and may be an array) then you must use the - * {@link #toJson(Object, Type)} or {@link #fromJson(String, Type)} method. Here is an + * {@link #toJson(Object, Type)} or {@link #fromJson(String, Type)} method. Here is an * example for serializing and deserializing a {@code ParameterizedType}: * *

diff --git a/gson/src/main/java/com/google/gson/JsonParseException.java b/gson/src/main/java/com/google/gson/JsonParseException.java
index 084f6612..c1f264d7 100644
--- a/gson/src/main/java/com/google/gson/JsonParseException.java
+++ b/gson/src/main/java/com/google/gson/JsonParseException.java
@@ -18,12 +18,12 @@ package com.google.gson;
 
 /**
  * This exception is raised if there is a serious issue that occurs during parsing of a Json
- * string.  One of the main usages for this class is for the Gson infrastructure.  If the incoming
+ * string. One of the main usages for this class is for the Gson infrastructure. If the incoming
  * Json is bad/malicious, an instance of this exception is raised.
  *
- * 

This exception is a {@link RuntimeException} because it is exposed to the client. Using a + *

This exception is a {@link RuntimeException} because it is exposed to the client. Using a * {@link RuntimeException} avoids bad coding practices on the client side where they catch the - * exception and do nothing. It is often the case that you want to blow up if there is a parsing + * exception and do nothing. It is often the case that you want to blow up if there is a parsing * error (i.e. often clients do not know how to recover from a {@link JsonParseException}.

* * @author Inderjeet Singh diff --git a/gson/src/main/java/com/google/gson/JsonStreamParser.java b/gson/src/main/java/com/google/gson/JsonStreamParser.java index f0438db3..1c0c9b9d 100644 --- a/gson/src/main/java/com/google/gson/JsonStreamParser.java +++ b/gson/src/main/java/com/google/gson/JsonStreamParser.java @@ -33,7 +33,7 @@ import com.google.gson.stream.MalformedJsonException; * *

This class is conditionally thread-safe (see Item 70, Effective Java second edition). To * properly use this class across multiple threads, you will need to add some external - * synchronization. For example: + * synchronization. For example: * *

  * JsonStreamParser parser = new JsonStreamParser("['first'] {'second':10} 'third'");
diff --git a/gson/src/main/java/com/google/gson/LongSerializationPolicy.java b/gson/src/main/java/com/google/gson/LongSerializationPolicy.java
index 7b732bab..bb2b6666 100644
--- a/gson/src/main/java/com/google/gson/LongSerializationPolicy.java
+++ b/gson/src/main/java/com/google/gson/LongSerializationPolicy.java
@@ -27,7 +27,7 @@ package com.google.gson;
 public enum LongSerializationPolicy {
   /**
    * This is the "default" serialization policy that will output a {@code long} object as a JSON
-   * number.  For example, assume an object has a long field named "f" then the serialized output
+   * number. For example, assume an object has a long field named "f" then the serialized output
    * would be:
    * {@code {"f":123}}.
    */
@@ -38,7 +38,7 @@ public enum LongSerializationPolicy {
   },
   
   /**
-   * Serializes a long value as a quoted string.  For example, assume an object has a long field 
+   * Serializes a long value as a quoted string. For example, assume an object has a long field 
    * named "f" then the serialized output would be:
    * {@code {"f":"123"}}.
    */
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 9e8e4b8d..82bb51cd 100644
--- a/gson/src/main/java/com/google/gson/annotations/SerializedName.java
+++ b/gson/src/main/java/com/google/gson/annotations/SerializedName.java
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
  *
  * 

This annotation will override any {@link com.google.gson.FieldNamingPolicy}, including * the default field naming policy, that may have been set on the {@link com.google.gson.Gson} - * instance. A different naming policy can set using the {@code GsonBuilder} class. See + * instance. A different naming policy can set using the {@code GsonBuilder} class. See * {@link com.google.gson.GsonBuilder#setFieldNamingPolicy(com.google.gson.FieldNamingPolicy)} * for more information.

* diff --git a/gson/src/main/java/com/google/gson/annotations/Until.java b/gson/src/main/java/com/google/gson/annotations/Until.java index 676a4b95..8c38552b 100644 --- a/gson/src/main/java/com/google/gson/annotations/Until.java +++ b/gson/src/main/java/com/google/gson/annotations/Until.java @@ -25,7 +25,7 @@ import java.lang.annotation.Target; /** * An annotation that indicates the version number until a member or a type should be present. * Basically, if Gson is created with a version number that exceeds the value stored in the - * {@code Until} annotation then the field will be ignored from the JSON output. This annotation + * {@code Until} annotation then the field will be ignored from the JSON output. This annotation * is useful to manage versioning of your JSON classes for a web-service. * *

diff --git a/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java b/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java index c53db7f2..8134ae2d 100644 --- a/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java +++ b/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java @@ -31,7 +31,7 @@ import junit.framework.TestCase; import java.lang.reflect.Type; /** - * Functional Test exercising custom deserialization only. When test applies to both + * Functional Test exercising custom deserialization only. When test applies to both * serialization and deserialization then add it to CustomTypeAdapterTest. * * @author Joel Leitch diff --git a/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java b/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java index f76dd18c..b7307c6f 100644 --- a/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java +++ b/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java @@ -87,20 +87,20 @@ public class DefaultTypeAdaptersTest extends TestCase { public void testClassSerialization() { try { - gson.toJson(String.class); + gson.toJson(String.class); } catch (UnsupportedOperationException expected) {} // Override with a custom type adapter for class. gson = new GsonBuilder().registerTypeAdapter(Class.class, new MyClassTypeAdapter()).create(); - assertEquals("\"java.lang.String\"", gson.toJson(String.class)); + assertEquals("\"java.lang.String\"", gson.toJson(String.class)); } public void testClassDeserialization() { try { - gson.fromJson("String.class", String.class.getClass()); + gson.fromJson("String.class", String.class.getClass()); } catch (UnsupportedOperationException expected) {} // Override with a custom type adapter for class. gson = new GsonBuilder().registerTypeAdapter(Class.class, new MyClassTypeAdapter()).create(); - assertEquals(String.class, gson.fromJson("java.lang.String", Class.class)); + assertEquals(String.class, gson.fromJson("java.lang.String", Class.class)); } public void testUrlSerialization() throws Exception { diff --git a/gson/src/test/java/com/google/gson/functional/InheritanceTest.java b/gson/src/test/java/com/google/gson/functional/InheritanceTest.java index b93ba0b5..475db838 100644 --- a/gson/src/test/java/com/google/gson/functional/InheritanceTest.java +++ b/gson/src/test/java/com/google/gson/functional/InheritanceTest.java @@ -217,7 +217,7 @@ public class InheritanceTest extends TestCase { return false; } } - return true; + return true; } boolean setContains(float... values) { @@ -235,7 +235,7 @@ public class InheritanceTest extends TestCase { return false; } } - return true; + return true; } public String getExpectedJson() { diff --git a/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java b/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java index aad55eeb..5437c876 100644 --- a/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java +++ b/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java @@ -33,7 +33,7 @@ import java.util.SortedSet; import java.util.TreeSet; /** - * Functional Test exercising custom serialization only. When test applies to both + * Functional Test exercising custom serialization only. When test applies to both * serialization and deserialization then add it to CustomTypeAdapterTest. * * @author Inderjeet Singh diff --git a/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java b/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java index 7939a8c8..a9b77f1d 100644 --- a/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java +++ b/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java @@ -163,7 +163,7 @@ public class NullObjectAndFieldTest extends TestCase { assertFalse(target.bool2); // test the default value of a primitive boolean field per JVM spec } - public static class ClassWithInitializedMembers { + public static class ClassWithInitializedMembers { // Using a mix of no-args constructor and field initializers // Also, some fields are intialized and some are not (so initialized per JVM spec) public static final String MY_STRING_DEFAULT = "string"; @@ -204,7 +204,7 @@ public class NullObjectAndFieldTest extends TestCase { Gson gson = new Gson(); String json = "{value:null}"; ObjectWithField obj = gson.fromJson(json, ObjectWithField.class); - assertNull(obj.value); + assertNull(obj.value); } public void testCustomTypeAdapterPassesNullSerialization() { diff --git a/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java b/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java index 190603de..85239c09 100644 --- a/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java +++ b/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java @@ -472,11 +472,11 @@ public class ParameterizedTypesTest extends TestCase { @SuppressWarnings("unused") int q2 = 20; } - private interface Measurable { + private interface Measurable { } - private interface Field { + private interface Field { } - private interface Immutable { + private interface Immutable { } public static final class Amount @@ -490,12 +490,12 @@ public class ParameterizedTypesTest extends TestCase { Amount amount = new Amount(); String json = gson.toJson(amount); assertTrue(json.contains("value")); - assertTrue(json.contains("30")); + assertTrue(json.contains("30")); } public void testDeepParameterizedTypeDeserialization() { String json = "{value:30}"; - Type type = new TypeToken>() {}.getType(); + Type type = new TypeToken>() {}.getType(); Amount amount = gson.fromJson(json, type); assertEquals(30, amount.value); } diff --git a/gson/src/test/java/com/google/gson/functional/VersioningTest.java b/gson/src/test/java/com/google/gson/functional/VersioningTest.java index bc526de0..2416fc06 100644 --- a/gson/src/test/java/com/google/gson/functional/VersioningTest.java +++ b/gson/src/test/java/com/google/gson/functional/VersioningTest.java @@ -88,7 +88,7 @@ public class VersioningTest extends TestCase { public void testIgnoreLaterVersionClassDeserialization() { Gson gson = builder.setVersion(1.0).create(); String json = "{\"a\":3,\"b\":4,\"c\":5,\"d\":6}"; - Version1_2 version1_2 = gson.fromJson(json, Version1_2.class); + Version1_2 version1_2 = gson.fromJson(json, Version1_2.class); // Since the class is versioned to be after 1.0, we expect null // This is the new behavior in Gson 2.0 assertNull(version1_2); diff --git a/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java b/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java index 431fc83d..9e180789 100644 --- a/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java +++ b/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java @@ -33,7 +33,7 @@ public final class UnsafeAllocatorInstantiationTest extends TestCase { } /** - * Ensure that the {@link java.lang.UnsupportedOperationException} is thrown when trying + * Ensure that the {@link java.lang.UnsupportedOperationException} is thrown when trying * to instantiate an interface */ public void testInterfaceInstantiation() { @@ -47,7 +47,7 @@ public final class UnsafeAllocatorInstantiationTest extends TestCase { } /** - * Ensure that the {@link java.lang.UnsupportedOperationException} is thrown when trying + * Ensure that the {@link java.lang.UnsupportedOperationException} is thrown when trying * to instantiate an abstract class */ public void testAbstractClassInstantiation() { diff --git a/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java b/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java index aaa577b5..0f7c428d 100644 --- a/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java +++ b/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java @@ -45,14 +45,16 @@ public class RecursiveTypesResolveTest extends TestCase { /** * Test simplest case of recursion. */ + public void testRecursiveResolveSimple() { TypeAdapter adapter = new Gson().getAdapter(Foo1.class); assertNotNull(adapter); } - // - // Real-world samples, found in Issues #603 and #440. - // + /** + * Real-world samples, found in Issues #603 and #440. + */ + public void testIssue603PrintStream() { TypeAdapter adapter = new Gson().getAdapter(PrintStream.class); assertNotNull(adapter); @@ -63,9 +65,9 @@ public class RecursiveTypesResolveTest extends TestCase { assertNotNull(adapter); } - // - // Tests belows check the behaviour of the methods changed for the fix - // + /** + * Tests belows check the behaviour of the methods changed for the fix. + */ public void testDoubleSupertype() { assertEquals($Gson$Types.supertypeOf(Number.class), @@ -87,9 +89,9 @@ public class RecursiveTypesResolveTest extends TestCase { $Gson$Types.subtypeOf($Gson$Types.supertypeOf(Number.class))); } - // - // tests for recursion while resolving type variables - // + /** + * Tests for recursion while resolving type variables. + */ private static class TestType { TestType superType; diff --git a/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java b/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java index cf444eee..d05cf4be 100644 --- a/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java +++ b/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java @@ -50,11 +50,11 @@ public class PerformanceTest extends TestCase { gson = new Gson(); } - public void testDummy() { + public void testDummy() { // This is here to prevent Junit for complaining when we disable all tests. - } + } - public void disabled_testStringDeserialization() { + public void disabled_testStringDeserialization() { StringBuilder sb = new StringBuilder(8096); sb.append("Error Yippie"); @@ -138,8 +138,8 @@ public class PerformanceTest extends TestCase { } sb.append(']'); String json = sb.toString(); - Type collectionType = new TypeToken>(){}.getType(); - List list = gson.fromJson(json, collectionType); + Type collectionType = new TypeToken>(){}.getType(); + List list = gson.fromJson(json, collectionType); assertEquals(count, list.size()); } @@ -203,7 +203,7 @@ public class PerformanceTest extends TestCase { } long t2 = System.currentTimeMillis(); long avg = (t2 - t1) / NUM_ITERATIONS; - System.out.printf("Serialize classes avg time: %d ms\n", avg); + System.out.printf("Serialize classes avg time: %d ms\n", avg); } public void disabled_testDeserializeClasses() { @@ -215,7 +215,7 @@ public class PerformanceTest extends TestCase { } long t2 = System.currentTimeMillis(); long avg = (t2 - t1) / NUM_ITERATIONS; - System.out.printf("Deserialize classes avg time: %d ms\n", avg); + System.out.printf("Deserialize classes avg time: %d ms\n", avg); } public void disable_testLargeObjectSerializationAndDeserialization() { @@ -249,7 +249,7 @@ public class PerformanceTest extends TestCase { } long t2 = System.currentTimeMillis(); long avg = (t2 - t1) / NUM_ITERATIONS; - System.out.printf("Serialize exposed classes avg time: %d ms\n", avg); + System.out.printf("Serialize exposed classes avg time: %d ms\n", avg); } public void disabled_testDeserializeExposedClasses() { @@ -261,7 +261,7 @@ public class PerformanceTest extends TestCase { } long t2 = System.currentTimeMillis(); long avg = (t2 - t1) / NUM_ITERATIONS; - System.out.printf("Deserialize exposed classes avg time: %d ms\n", avg); + System.out.printf("Deserialize exposed classes avg time: %d ms\n", avg); } public void disabled_testLargeGsonMapRoundTrip() throws Exception { @@ -343,4 +343,4 @@ public class PerformanceTest extends TestCase { this.field = field; } } -} +} \ No newline at end of file