From 756131d869465ac70abb9595653ea967e6812231 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Sun, 4 Dec 2011 10:24:07 +0000 Subject: [PATCH] removed Eclipse 3.7 warnings. --- gson/src/main/java/com/google/gson/Gson.java | 10 ++++++---- .../src/main/java/com/google/gson/TreeTypeAdapter.java | 4 ++-- .../java/com/google/gson/ObjectTypeAdapterTest.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index 4ba56176..5ec95615 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -126,7 +126,8 @@ public final class Gson { private final boolean prettyPrinting; final JsonDeserializationContext deserializationContext = new JsonDeserializationContext() { - public T deserialize(JsonElement json, Type typeOfT) throws JsonParseException { + @SuppressWarnings("unchecked") + public T deserialize(JsonElement json, Type typeOfT) throws JsonParseException { return (T) fromJson(json, typeOfT); } }; @@ -174,7 +175,6 @@ public final class Gson { * {@link GsonBuilder#excludeFieldsWithModifiers(int...)}. * */ - @SuppressWarnings("unchecked") public Gson() { this(Excluder.DEFAULT, FieldNamingPolicy.IDENTITY, Collections.>emptyMap(), false, false, DEFAULT_JSON_NON_EXECUTABLE, @@ -330,6 +330,7 @@ public final class Gson { * @throws IllegalArgumentException if this GSON cannot serialize and * deserialize {@code type}. */ + @SuppressWarnings("unchecked") public TypeAdapter getAdapter(TypeToken type) { TypeAdapter cached = typeTokenCache.get(type); if (cached != null) { @@ -337,7 +338,7 @@ public final class Gson { } Map, FutureTypeAdapter> threadCalls = calls.get(); - @SuppressWarnings("unchecked") // the key and value type parameters always agree + // the key and value type parameters always agree FutureTypeAdapter ongoingCall = (FutureTypeAdapter) threadCalls.get(type); if (ongoingCall != null) { return ongoingCall; @@ -434,7 +435,6 @@ public final class Gson { * @return Json representation of {@code src} * @since 1.4 */ - @SuppressWarnings({"unchecked", "rawtypes"}) // the caller is required to make src and typeOfSrc consistent public JsonElement toJsonTree(Object src, Type typeOfSrc) { JsonElementWriter writer = new JsonElementWriter(); toJson(src, typeOfSrc, writer); @@ -716,6 +716,7 @@ public final class Gson { * @throws JsonSyntaxException if json is not a valid representation for an object of type * @since 1.2 */ + @SuppressWarnings("unchecked") public T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException { JsonReader jsonReader = new JsonReader(json); T object = (T) fromJson(jsonReader, typeOfT); @@ -811,6 +812,7 @@ public final class Gson { * @throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT * @since 1.3 */ + @SuppressWarnings("unchecked") public T fromJson(JsonElement json, Type typeOfT) throws JsonSyntaxException { if (json == null) { return null; diff --git a/gson/src/main/java/com/google/gson/TreeTypeAdapter.java b/gson/src/main/java/com/google/gson/TreeTypeAdapter.java index 1b18582e..035ef052 100644 --- a/gson/src/main/java/com/google/gson/TreeTypeAdapter.java +++ b/gson/src/main/java/com/google/gson/TreeTypeAdapter.java @@ -113,10 +113,10 @@ final class TreeTypeAdapter extends TypeAdapter { private SingleTypeFactory(Object typeAdapter, TypeToken exactType, boolean matchRawType, Class hierarchyType) { serializer = typeAdapter instanceof JsonSerializer - ? (JsonSerializer) typeAdapter + ? (JsonSerializer) typeAdapter : null; deserializer = typeAdapter instanceof JsonDeserializer - ? (JsonDeserializer) typeAdapter + ? (JsonDeserializer) typeAdapter : null; $Gson$Preconditions.checkArgument(serializer != null || deserializer != null); this.exactType = exactType; diff --git a/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java b/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java index 8066cedf..b5e800d7 100644 --- a/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java +++ b/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java @@ -33,7 +33,6 @@ public final class ObjectTypeAdapterTest extends TestCase { assertEquals(3, map.size()); } - @SuppressWarnings("unused") public void testSerialize() throws Exception { Object object = new RuntimeType(); assertEquals("{'a':5,'b':[1,2,null]}", adapter.toJson(object).replace("\"", "'")); @@ -43,6 +42,7 @@ public final class ObjectTypeAdapterTest extends TestCase { assertEquals("{}", adapter.toJson(new Object())); } + @SuppressWarnings("unused") private class RuntimeType { Object a = 5; Object b = Arrays.asList(1, 2, null);