Skip to content

Commit

Permalink
Code cleanup (Removed spaces) (#1474)
Browse files Browse the repository at this point in the history
* Removed double spaces in comments

* Unified comments

* Removed space

* Removed spaces in code
  • Loading branch information
Lorenz Nickel authored and inder123 committed Mar 3, 2019
1 parent 4d942db commit b75e1bb
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 49 deletions.
2 changes: 1 addition & 1 deletion gson/src/main/java/com/google/gson/ExclusionStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* 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.
*
* <p>The following are a few examples that shows how you can use this exclusion mechanism.
Expand Down
4 changes: 2 additions & 2 deletions gson/src/main/java/com/google/gson/FieldNamingStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
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
Expand Down
2 changes: 1 addition & 1 deletion gson/src/main/java/com/google/gson/Gson.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
*
* <p>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}:
*
* <pre>
Expand Down
6 changes: 3 additions & 3 deletions gson/src/main/java/com/google/gson/JsonParseException.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

/**
* 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.
*
* <p>This exception is a {@link RuntimeException} because it is exposed to the client. Using a
* <p>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}.</p>
*
* @author Inderjeet Singh
Expand Down
2 changes: 1 addition & 1 deletion gson/src/main/java/com/google/gson/JsonStreamParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* <p>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:
*
* <pre>
* JsonStreamParser parser = new JsonStreamParser("['first'] {'second':10} 'third'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
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}}.
*/
Expand All @@ -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"}}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* <p>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.</p>
*
Expand Down
2 changes: 1 addition & 1 deletion gson/src/main/java/com/google/gson/annotations/Until.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* 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.
*
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ protected void tearDown() throws Exception {

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ boolean queueContains(long... values) {
return false;
}
}
return true;
return true;
}

boolean setContains(float... values) {
Expand All @@ -235,7 +235,7 @@ boolean sortedSetContains(char... values) {
return false;
}
}
return true;
return true;
}

public String getExpectedJson() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void testAbsentJsonElementsAreSetToNull() {
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";
Expand Down Expand Up @@ -204,7 +204,7 @@ public void testExplicitNullSetsFieldToNullDuringDeserialization() {
Gson gson = new Gson();
String json = "{value:null}";
ObjectWithField obj = gson.fromJson(json, ObjectWithField.class);
assertNull(obj.value);
assertNull(obj.value);
}

public void testCustomTypeAdapterPassesNullSerialization() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,11 @@ private static class MyQuantity extends Quantity {
@SuppressWarnings("unused")
int q2 = 20;
}
private interface Measurable<T> {
private interface Measurable<T> {
}
private interface Field<T> {
private interface Field<T> {
}
private interface Immutable {
private interface Immutable {
}

public static final class Amount<Q extends Quantity>
Expand All @@ -490,12 +490,12 @@ public void testDeepParameterizedTypeSerialization() {
Amount<MyQuantity> amount = new Amount<MyQuantity>();
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<Amount<MyQuantity>>() {}.getType();
Type type = new TypeToken<Amount<MyQuantity>>() {}.getType();
Amount<MyQuantity> amount = gson.fromJson(json, type);
assertEquals(30, amount.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void testIgnoreLaterVersionClassSerialization() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static class ConcreteClass {
}

/**
* 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() {
Expand All @@ -47,7 +47,7 @@ public void testInterfaceInstantiation() {
}

/**
* 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ private static class Foo2<B> {
/**
* Test simplest case of recursion.
*/

public void testRecursiveResolveSimple() {
TypeAdapter<Foo1> 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<PrintStream> adapter = new Gson().getAdapter(PrintStream.class);
assertNotNull(adapter);
Expand All @@ -63,9 +65,9 @@ public void testIssue440WeakReference() throws Exception {
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),
Expand All @@ -87,9 +89,9 @@ public void testSubSupertype() {
$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<X> {
TestType<? super X> superType;
Expand Down
20 changes: 10 additions & 10 deletions gson/src/test/java/com/google/gson/metrics/PerformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ protected void setUp() throws Exception {
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");

Expand Down Expand Up @@ -138,8 +138,8 @@ public void disabled_testLargeCollectionDeserialization() {
}
sb.append(']');
String json = sb.toString();
Type collectionType = new TypeToken<ArrayList<CollectionEntry>>(){}.getType();
List<CollectionEntry> list = gson.fromJson(json, collectionType);
Type collectionType = new TypeToken<ArrayList<CollectionEntry>>(){}.getType();
List<CollectionEntry> list = gson.fromJson(json, collectionType);
assertEquals(count, list.size());
}

Expand Down Expand Up @@ -203,7 +203,7 @@ public void disabled_testSerializeClasses() {
}
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() {
Expand All @@ -215,7 +215,7 @@ public void disabled_testDeserializeClasses() {
}
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() {
Expand Down Expand Up @@ -249,7 +249,7 @@ public void disabled_testSerializeExposedClasses() {
}
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() {
Expand All @@ -261,7 +261,7 @@ public void disabled_testDeserializeExposedClasses() {
}
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 {
Expand Down Expand Up @@ -343,4 +343,4 @@ private static final class ClassWithExposedField {
this.field = field;
}
}
}
}

0 comments on commit b75e1bb

Please sign in to comment.