removed Java 1.5 warnings
This commit is contained in:
parent
66649a1a62
commit
82771f006c
|
@ -319,6 +319,7 @@ public final class GsonBuilder {
|
|||
* {@link JsonSerializer}, and a {@link JsonDeserializer} interfaces.
|
||||
* @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
|
||||
Preconditions.checkArgument(typeAdapter instanceof JsonSerializer
|
||||
|| typeAdapter instanceof JsonDeserializer || typeAdapter instanceof InstanceCreator);
|
||||
|
|
|
@ -55,6 +55,7 @@ final class TypeInfoFactory {
|
|||
return new TypeInfo(actualType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Type getActualType(
|
||||
Type typeToEvaluate, Type parentType, Class<?> rawParentClass) {
|
||||
if (typeToEvaluate instanceof Class) {
|
||||
|
|
|
@ -31,6 +31,7 @@ final class TypeInfoMap {
|
|||
private final Type keyType;
|
||||
private final Type valueType;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public TypeInfoMap(Type mapType) {
|
||||
if (mapType instanceof Class && Properties.class.isAssignableFrom((Class<?>) mapType)) {
|
||||
keyType = String.class;
|
||||
|
|
|
@ -40,6 +40,7 @@ final class TypeUtils {
|
|||
* </pre>
|
||||
* <code>TypeUtils.getActualTypeForFirstTypeVariable(fooType)</code> will return Integer.class.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static Type getActualTypeForFirstTypeVariable(Type type) {
|
||||
if (type instanceof Class) {
|
||||
return Object.class;
|
||||
|
@ -53,6 +54,7 @@ final class TypeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static boolean isArray(Type type) {
|
||||
if (type instanceof Class) {
|
||||
return ((Class<?>)type).isArray();
|
||||
|
@ -66,6 +68,7 @@ final class TypeUtils {
|
|||
/**
|
||||
* This method returns the actual raw class associated with the specified type.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static Class<?> toRawClass(Type type) {
|
||||
if (type instanceof Class) {
|
||||
return (Class<?>) type;
|
||||
|
|
|
@ -85,6 +85,7 @@ public abstract class TypeToken<T> {
|
|||
/**
|
||||
* Gets type from super class's type parameter.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static Type getSuperclassTypeParameter(Class<?> subclass) {
|
||||
Type superclass = subclass.getGenericSuperclass();
|
||||
if (superclass instanceof Class) {
|
||||
|
@ -154,6 +155,7 @@ public abstract class TypeToken<T> {
|
|||
/**
|
||||
* Check if this type is assignable from the given Type.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean isAssignableFrom(Type from) {
|
||||
if (from == null) {
|
||||
return false;
|
||||
|
@ -188,6 +190,7 @@ public abstract class TypeToken<T> {
|
|||
* Private helper function that performs some assignability checks for
|
||||
* the provided GenericArrayType.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean isAssignableFrom(Type from, GenericArrayType to) {
|
||||
Type toGenericComponentType = to.getGenericComponentType();
|
||||
if (toGenericComponentType instanceof ParameterizedType) {
|
||||
|
@ -213,6 +216,7 @@ public abstract class TypeToken<T> {
|
|||
* Private recursive helper function to actually do the type-safe checking
|
||||
* of assignability.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean isAssignableFrom(Type from, ParameterizedType to,
|
||||
Map<String, Type> typeVarMap) {
|
||||
|
||||
|
@ -289,6 +293,7 @@ public abstract class TypeToken<T> {
|
|||
* Checks if two types are the same or are equivalent under a variable mapping
|
||||
* given in the type map that was provided.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean matches(Type from, Type to,
|
||||
Map<String, Type> typeMap) {
|
||||
if (to.equals(from)) return true;
|
||||
|
|
|
@ -51,6 +51,7 @@ public class ExposeAnnotationBasedExclusionStrategyTest extends TestCase {
|
|||
assertFalse(strategy.shouldSkipField(f));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class MockObject {
|
||||
@Expose
|
||||
public final int exposedField = 0;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.google.gson;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
|
|
@ -53,6 +53,7 @@ public class SerializedNameAnnotationInterceptingNamingPolicyTest extends TestCa
|
|||
assertEquals(fieldName, policy.translateName(f));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class SomeObject {
|
||||
@SerializedName(ANNOTATED_FIELD_NAME) public final int fieldWithAnnotation = 1;
|
||||
public final int fieldWithoutAnnotation = 1;
|
||||
|
|
|
@ -223,6 +223,7 @@ public class TypeInfoFactoryTest extends TestCase {
|
|||
assertEquals(List[].class, typeInfo.getRawClass());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class ObjectWithDifferentFields<T> {
|
||||
public static enum TestEnum {
|
||||
TEST_1, TEST_2;
|
||||
|
|
|
@ -66,6 +66,7 @@ public class VersionExclusionStrategyTest extends TestCase {
|
|||
|
||||
@Since(VERSION)
|
||||
private static class MockObject {
|
||||
@SuppressWarnings("unused")
|
||||
@Since(VERSION)
|
||||
public final int someField = 0;
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ public class CollectionTest extends TestCase {
|
|||
private static class ObjectWithWildcardCollection {
|
||||
private final Collection<? extends BagOfPrimitives> collection;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
public ObjectWithWildcardCollection() {
|
||||
this(Collections.EMPTY_LIST);
|
||||
}
|
||||
|
@ -299,6 +299,8 @@ public class CollectionTest extends TestCase {
|
|||
|
||||
private static class Entry {
|
||||
int value;
|
||||
// For use by Gson
|
||||
@SuppressWarnings("unused")
|
||||
Entry() {
|
||||
this(10);
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ public class ConcurrencyTest extends TestCase {
|
|||
assertFalse(failed.get());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class MyObject {
|
||||
String a;
|
||||
String b;
|
||||
|
|
|
@ -65,6 +65,7 @@ public class CustomDeserializerTest extends TestCase {
|
|||
private static class DataHolder {
|
||||
private final String data;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public DataHolder() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -81,6 +82,7 @@ public class CustomDeserializerTest extends TestCase {
|
|||
private static class DataHolderWrapper {
|
||||
private final DataHolder wrappedData;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public DataHolderWrapper() {
|
||||
this(new DataHolder(DEFAULT_VALUE));
|
||||
}
|
||||
|
|
|
@ -289,6 +289,7 @@ public class DefaultTypeAdaptersTest extends TestCase {
|
|||
|
||||
private static class ClassWithBigDecimal {
|
||||
BigDecimal value;
|
||||
@SuppressWarnings("unused")
|
||||
ClassWithBigDecimal() { }
|
||||
ClassWithBigDecimal(String value) {
|
||||
this.value = new BigDecimal(value);
|
||||
|
@ -300,6 +301,7 @@ public class DefaultTypeAdaptersTest extends TestCase {
|
|||
|
||||
private static class ClassWithBigInteger {
|
||||
BigInteger value;
|
||||
@SuppressWarnings("unused")
|
||||
ClassWithBigInteger() { }
|
||||
ClassWithBigInteger(String value) {
|
||||
this.value = new BigInteger(value);
|
||||
|
|
|
@ -117,6 +117,7 @@ public class ExposeFieldsTest extends TestCase {
|
|||
@Expose(deserialize = false) final double d;
|
||||
@Expose(serialize = false, deserialize = false) final char e;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
ClassWithExposedFields() {
|
||||
this(null, null);
|
||||
}
|
||||
|
@ -141,10 +142,6 @@ public class ExposeFieldsTest extends TestCase {
|
|||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getExpectedJsonWithoutAnnotations() {
|
||||
return String.format("{\"a\":%d,\"b\":%d,\"c\":%d,\"d\":%f,\"e\":\"%c\"}", a, b, c, d, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClassWithNoExposedFields {
|
||||
|
@ -170,6 +167,7 @@ public class ExposeFieldsTest extends TestCase {
|
|||
@Expose
|
||||
private final SomeInterface interfaceField;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ClassWithInterfaceField() {
|
||||
this(null);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ public class JsonTreeTest extends TestCase {
|
|||
}
|
||||
|
||||
private static class SubTypeOfBagOfPrimitives extends BagOfPrimitives {
|
||||
@SuppressWarnings("unused")
|
||||
float f = 1.2F;
|
||||
public SubTypeOfBagOfPrimitives(long l, int i, boolean b, String string, float f) {
|
||||
super(l, i, b, string);
|
||||
|
|
|
@ -172,6 +172,7 @@ public class MapTest extends TestCase {
|
|||
private static class MyParameterizedMap<K, V> extends LinkedHashMap<K, V> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int foo = 10;
|
||||
}
|
||||
|
||||
|
@ -248,6 +249,7 @@ public class MapTest extends TestCase {
|
|||
private static class MyMap extends LinkedHashMap<String, String> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int foo = 10;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ public class NamingPolicyTest extends TestCase {
|
|||
assertEquals("{\"a\":3.0}", actual);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class ClassWithDuplicateFields {
|
||||
public Integer a;
|
||||
@SerializedName("a") public Double b;
|
||||
|
|
|
@ -151,6 +151,7 @@ public class NullObjectAndFieldTest extends TestCase {
|
|||
private Long value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class ClassWithMembers {
|
||||
String str;
|
||||
int[] array;
|
||||
|
|
|
@ -351,6 +351,7 @@ public class ObjectTest extends TestCase {
|
|||
assertTrue(json.contains("abc"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class ClassWithObjectField {
|
||||
Object member;
|
||||
}
|
||||
|
@ -377,6 +378,7 @@ public class ObjectTest extends TestCase {
|
|||
}
|
||||
|
||||
private static class Parent {
|
||||
@SuppressWarnings("unused")
|
||||
int value1 = 1;
|
||||
private class Child {
|
||||
int value2 = 2;
|
||||
|
@ -389,6 +391,8 @@ public class ObjectTest extends TestCase {
|
|||
private Set<Float> set;
|
||||
private SortedSet<Character> sortedSet;
|
||||
|
||||
// For use by Gson
|
||||
@SuppressWarnings("unused")
|
||||
ClassWithSubInterfacesOfCollection() {
|
||||
}
|
||||
|
||||
|
@ -481,6 +485,7 @@ public class ObjectTest extends TestCase {
|
|||
private static class SubTypeOfNested extends Nested {
|
||||
private final long value = 5;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public SubTypeOfNested() {
|
||||
this(null, null);
|
||||
}
|
||||
|
@ -585,7 +590,7 @@ public class ObjectTest extends TestCase {
|
|||
public void testArrayOfObjectsWithoutTypeInfoDeserialization() {
|
||||
String json = "[1,'abc',{a:1},5]";
|
||||
try {
|
||||
Object[] objs = gson.fromJson(json, Object[].class);
|
||||
gson.fromJson(json, Object[].class);
|
||||
} catch (JsonParseException expected) {
|
||||
}
|
||||
}
|
||||
|
@ -593,7 +598,7 @@ public class ObjectTest extends TestCase {
|
|||
public void testArrayWithoutTypeInfoDeserialization() {
|
||||
String json = "[1,'abc',[1,2],5]";
|
||||
try {
|
||||
Object[] objs = gson.fromJson(json, Object[].class);
|
||||
gson.fromJson(json, Object[].class);
|
||||
} catch (JsonParseException expected) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,6 +271,7 @@ public class ParameterizedTypesTest extends TestCase {
|
|||
private final List<? extends T> listOfWildcardTypeParameters;
|
||||
private final List<? extends T>[] arrayOfListOfWildcardTypeParameters;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ObjectWithTypeVariables() {
|
||||
this(null, null, null, null, null, null);
|
||||
}
|
||||
|
@ -386,6 +387,7 @@ public class ParameterizedTypesTest extends TestCase {
|
|||
C c;
|
||||
D d;
|
||||
E e;
|
||||
@SuppressWarnings("unused")
|
||||
MultiParameters() {
|
||||
}
|
||||
MultiParameters(A a, B b, C c, D d, E e) {
|
||||
|
@ -461,9 +463,11 @@ public class ParameterizedTypesTest extends TestCase {
|
|||
|
||||
// Begin: tests to reproduce issue 103
|
||||
private static class Quantity {
|
||||
@SuppressWarnings("unused")
|
||||
int q = 10;
|
||||
}
|
||||
private static class MyQuantity extends Quantity {
|
||||
@SuppressWarnings("unused")
|
||||
int q2 = 20;
|
||||
}
|
||||
private interface Measurable<T> {
|
||||
|
|
|
@ -72,6 +72,7 @@ public class PerformanceTest extends TestCase {
|
|||
private static class ExceptionHolder {
|
||||
public final String message;
|
||||
public final String stackTrace;
|
||||
@SuppressWarnings("unused")
|
||||
public ExceptionHolder() {
|
||||
this("", "");
|
||||
}
|
||||
|
@ -81,6 +82,7 @@ public class PerformanceTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class CollectionEntry {
|
||||
final String name;
|
||||
final String value;
|
||||
|
@ -140,7 +142,7 @@ public class PerformanceTest extends TestCase {
|
|||
for (int i = 0; i < size; ++i) {
|
||||
ba[i] = 0x05;
|
||||
}
|
||||
String json = gson.toJson(ba);
|
||||
gson.toJson(ba);
|
||||
System.out.printf("Gson could serialize a byte array of size: %d\n", size);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user