From 95e7f28cfaae9cad4e801e229e7d34a4cc832b2d Mon Sep 17 00:00:00 2001 From: "moandji.ezana" Date: Thu, 2 Jul 2015 07:31:51 +0200 Subject: [PATCH] Remove warnings --- .../java/com/moandjiezana/toml/ArrayValueWriter.java | 8 ++++---- .../java/com/moandjiezana/toml/MapValueWriter.java | 9 +++++---- .../com/moandjiezana/toml/ObjectValueWriter.java | 4 ++-- .../moandjiezana/toml/PrimitiveArrayValueWriter.java | 12 ++++++------ .../com/moandjiezana/toml/TableArrayValueWriter.java | 6 +++--- src/test/java/com/moandjiezana/toml/TomlTest.java | 1 - 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/moandjiezana/toml/ArrayValueWriter.java b/src/main/java/com/moandjiezana/toml/ArrayValueWriter.java index 68d1364..2e51d28 100644 --- a/src/main/java/com/moandjiezana/toml/ArrayValueWriter.java +++ b/src/main/java/com/moandjiezana/toml/ArrayValueWriter.java @@ -28,8 +28,8 @@ abstract class ArrayValueWriter implements ValueWriter { } @SuppressWarnings("unchecked") - protected Collection normalize(Object value) { - Collection collection; + protected Collection normalize(Object value) { + Collection collection; if (value.getClass().isArray()) { // Arrays.asList() interprets an array as a single element, @@ -40,7 +40,7 @@ abstract class ArrayValueWriter implements ValueWriter { collection.add(elem); } } else { - collection = (Collection) value; + collection = (Collection) value; } return collection; @@ -54,7 +54,7 @@ abstract class ArrayValueWriter implements ValueWriter { return null; } } else { - Collection collection = (Collection) value; + Collection collection = (Collection) value; if (collection.size() > 0) { return collection.iterator().next(); } diff --git a/src/main/java/com/moandjiezana/toml/MapValueWriter.java b/src/main/java/com/moandjiezana/toml/MapValueWriter.java index 0be9b07..2625c1a 100644 --- a/src/main/java/com/moandjiezana/toml/MapValueWriter.java +++ b/src/main/java/com/moandjiezana/toml/MapValueWriter.java @@ -20,7 +20,7 @@ class MapValueWriter implements ValueWriter { @Override public void write(Object value, WriterContext context) { - Map from = (Map) value; + Map from = (Map) value; if (hasPrimitiveValues(from, context)) { context.writeKey(); @@ -28,8 +28,9 @@ class MapValueWriter implements ValueWriter { // Render primitive types and arrays of primitive first so they are // grouped under the same table (if there is one) - for (Object key : from.keySet()) { - Object fromValue = from.get(key); + for (Map.Entry entry : from.entrySet()) { + Object key = entry.getKey(); + Object fromValue = entry.getValue(); if (fromValue == null) { continue; } @@ -77,7 +78,7 @@ class MapValueWriter implements ValueWriter { return stringKey; } - private static boolean hasPrimitiveValues(Map values, WriterContext context) { + private static boolean hasPrimitiveValues(Map values, WriterContext context) { for (Object key : values.keySet()) { Object fromValue = values.get(key); if (fromValue == null) { diff --git a/src/main/java/com/moandjiezana/toml/ObjectValueWriter.java b/src/main/java/com/moandjiezana/toml/ObjectValueWriter.java index b0474a2..68dbf6b 100644 --- a/src/main/java/com/moandjiezana/toml/ObjectValueWriter.java +++ b/src/main/java/com/moandjiezana/toml/ObjectValueWriter.java @@ -34,7 +34,7 @@ class ObjectValueWriter implements ValueWriter { return false; } - static private Set getFieldsForClass(Class cls) { + static private Set getFieldsForClass(Class cls) { Set fields = new LinkedHashSet(Arrays.asList(cls.getDeclaredFields())); getSuperClassFields(cls.getSuperclass(), fields); @@ -50,7 +50,7 @@ class ObjectValueWriter implements ValueWriter { return prunedFields; } - static private void getSuperClassFields(Class cls, Set fields) { + static private void getSuperClassFields(Class cls, Set fields) { if (cls == Object.class) { return; } diff --git a/src/main/java/com/moandjiezana/toml/PrimitiveArrayValueWriter.java b/src/main/java/com/moandjiezana/toml/PrimitiveArrayValueWriter.java index adcf05a..eb0082a 100644 --- a/src/main/java/com/moandjiezana/toml/PrimitiveArrayValueWriter.java +++ b/src/main/java/com/moandjiezana/toml/PrimitiveArrayValueWriter.java @@ -13,8 +13,8 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter { } @Override - public void write(Object value, WriterContext context) { - Collection values = normalize(value); + public void write(Object o, WriterContext context) { + Collection values = normalize(o); context.write('['); context.writeArrayDelimiterPadding(); @@ -22,12 +22,12 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter { boolean first = true; ValueWriter firstWriter = null; - for (Object elem : values) { + for (Object value : values) { if (first) { - firstWriter = WRITERS.findWriterFor(elem); + firstWriter = WRITERS.findWriterFor(value); first = false; } else { - ValueWriter writer = WRITERS.findWriterFor(elem); + ValueWriter writer = WRITERS.findWriterFor(value); if (writer != firstWriter) { throw new IllegalStateException( context.getContextPath() + @@ -38,7 +38,7 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter { context.write(", "); } - WRITERS.write(elem, context); + WRITERS.write(value, context); } context.writeArrayDelimiterPadding(); diff --git a/src/main/java/com/moandjiezana/toml/TableArrayValueWriter.java b/src/main/java/com/moandjiezana/toml/TableArrayValueWriter.java index c8b3499..5390d5b 100644 --- a/src/main/java/com/moandjiezana/toml/TableArrayValueWriter.java +++ b/src/main/java/com/moandjiezana/toml/TableArrayValueWriter.java @@ -1,9 +1,9 @@ package com.moandjiezana.toml; -import java.util.Collection; - import static com.moandjiezana.toml.ValueWriters.WRITERS; +import java.util.Collection; + class TableArrayValueWriter extends ArrayValueWriter { static final ValueWriter TABLE_ARRAY_VALUE_WRITER = new TableArrayValueWriter(); @@ -14,7 +14,7 @@ class TableArrayValueWriter extends ArrayValueWriter { @Override public void write(Object value, WriterContext context) { - Collection values = normalize(value); + Collection values = normalize(value); WriterContext subContext = context.pushTableFromArray(); diff --git a/src/test/java/com/moandjiezana/toml/TomlTest.java b/src/test/java/com/moandjiezana/toml/TomlTest.java index 5aec9c7..eb31040 100644 --- a/src/test/java/com/moandjiezana/toml/TomlTest.java +++ b/src/test/java/com/moandjiezana/toml/TomlTest.java @@ -11,7 +11,6 @@ import java.util.Calendar; import java.util.TimeZone; import org.hamcrest.Matchers; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;