Clean up warnings.

This commit is contained in:
Joel Leitch 2011-03-15 15:38:17 +00:00
parent e57ef0908b
commit ba0cd254a9
6 changed files with 11 additions and 11 deletions

View File

@ -31,8 +31,7 @@ final class FieldNamingStrategy2Adapter implements FieldNamingStrategy2 {
Preconditions.checkNotNull(adaptee);
this.adaptee = adaptee;
}
@SuppressWarnings("deprecation")
public String translateName(FieldAttributes f) {
return adaptee.translateName(f.getFieldObject());
}

View File

@ -218,12 +218,9 @@ public final class Gson {
* @since 1.4
*/
public JsonElement toJsonTree(Object src, Type typeOfSrc) {
if (src == null) {
return JsonNull.createJsonNull();
}
JsonSerializationContextDefault context = new JsonSerializationContextDefault(
createDefaultObjectNavigatorFactory(serializationExclusionStrategy), serializeNulls, serializers);
return context.serialize(src, typeOfSrc, true);
return context.serialize(src, typeOfSrc);
}
/**

View File

@ -46,10 +46,13 @@ final class JsonSerializationContextDefault implements JsonSerializationContext
}
public JsonElement serialize(Object src, Type typeOfSrc) {
if (src == null) {
return JsonNull.createJsonNull();
}
return serialize(src, typeOfSrc, true);
}
public JsonElement serialize(Object src, Type typeOfSrc, boolean preserveType) {
JsonElement serialize(Object src, Type typeOfSrc, boolean preserveType) {
ObjectNavigator on = factory.create(new ObjectTypePair(src, typeOfSrc, preserveType));
JsonSerializationVisitor visitor =
new JsonSerializationVisitor(factory, serializeNulls, serializers, this, ancestors);

View File

@ -30,8 +30,9 @@ package com.google.gson;
* @author Joel Leitch
*/
final class Preconditions {
public static void checkNotNull(Object obj) {
public static <T> T checkNotNull(T obj) {
checkArgument(obj != null);
return obj;
}
public static void checkArgument(boolean condition) {

View File

@ -421,7 +421,7 @@ public final class Types {
* Returns the declaring class of {@code typeVariable}, or {@code null} if it was not declared by
* a class.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings("unchecked")
private static Class<?> declaringClassOf(TypeVariable typeVariable) {
GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
return genericDeclaration instanceof Class
@ -438,7 +438,7 @@ public final class Types {
private final Type rawType;
private final Type[] typeArguments;
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings("unchecked")
public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
// require an owner type if the raw type needs it
if (rawType instanceof Class<?>) {

View File

@ -45,7 +45,7 @@ public class PrintFormattingTest extends TestCase {
gson = new Gson();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings("unchecked")
public void testCompactFormattingLeavesNoWhiteSpace() {
List list = new ArrayList();
list.add(new BagOfPrimitives());