Code cleanup (Removed spaces) (#1474)

* Removed double spaces in comments

* Unified comments

* Removed space

* Removed spaces in code
This commit is contained in:
Lorenz Nickel 2019-03-03 20:18:06 +01:00 committed by inder123
parent 4d942db168
commit b75e1bbc79
18 changed files with 51 additions and 49 deletions

View File

@ -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.
*
* <p>The following are a few examples that shows how you can use this exclusion mechanism.

View File

@ -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

View File

@ -80,7 +80,7 @@ import com.google.gson.stream.MalformedJsonException;
*
* <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>

View File

@ -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.
*
* <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

View File

@ -33,7 +33,7 @@ import com.google.gson.stream.MalformedJsonException;
*
* <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'");

View File

@ -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"}}.
*/

View File

@ -28,7 +28,7 @@ import java.lang.annotation.Target;
*
* <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>
*

View File

@ -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.
*
* <p>

View File

@ -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

View File

@ -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 {

View File

@ -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() {

View File

@ -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

View File

@ -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() {

View File

@ -472,11 +472,11 @@ public class ParameterizedTypesTest extends TestCase {
@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>
@ -490,12 +490,12 @@ public class ParameterizedTypesTest extends TestCase {
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);
}

View File

@ -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);

View File

@ -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() {

View File

@ -45,14 +45,16 @@ public class RecursiveTypesResolveTest extends TestCase {
/**
* 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);
@ -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<X> {
TestType<? super X> superType;

View File

@ -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<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());
}
@ -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;
}
}
}
}