Remove warnings

This commit is contained in:
moandji.ezana 2015-07-02 07:31:51 +02:00
parent 47bd5022f1
commit 95e7f28cfa
6 changed files with 20 additions and 20 deletions

View file

@ -28,8 +28,8 @@ abstract class ArrayValueWriter implements ValueWriter {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected Collection normalize(Object value) { protected Collection<?> normalize(Object value) {
Collection collection; Collection<Object> collection;
if (value.getClass().isArray()) { if (value.getClass().isArray()) {
// Arrays.asList() interprets an array as a single element, // Arrays.asList() interprets an array as a single element,
@ -40,7 +40,7 @@ abstract class ArrayValueWriter implements ValueWriter {
collection.add(elem); collection.add(elem);
} }
} else { } else {
collection = (Collection) value; collection = (Collection<Object>) value;
} }
return collection; return collection;
@ -54,7 +54,7 @@ abstract class ArrayValueWriter implements ValueWriter {
return null; return null;
} }
} else { } else {
Collection collection = (Collection) value; Collection<?> collection = (Collection<?>) value;
if (collection.size() > 0) { if (collection.size() > 0) {
return collection.iterator().next(); return collection.iterator().next();
} }

View file

@ -20,7 +20,7 @@ class MapValueWriter implements ValueWriter {
@Override @Override
public void write(Object value, WriterContext context) { public void write(Object value, WriterContext context) {
Map from = (Map) value; Map<?, ?> from = (Map<?, ?>) value;
if (hasPrimitiveValues(from, context)) { if (hasPrimitiveValues(from, context)) {
context.writeKey(); context.writeKey();
@ -28,8 +28,9 @@ class MapValueWriter implements ValueWriter {
// Render primitive types and arrays of primitive first so they are // Render primitive types and arrays of primitive first so they are
// grouped under the same table (if there is one) // grouped under the same table (if there is one)
for (Object key : from.keySet()) { for (Map.Entry<?, ?> entry : from.entrySet()) {
Object fromValue = from.get(key); Object key = entry.getKey();
Object fromValue = entry.getValue();
if (fromValue == null) { if (fromValue == null) {
continue; continue;
} }
@ -77,7 +78,7 @@ class MapValueWriter implements ValueWriter {
return stringKey; return stringKey;
} }
private static boolean hasPrimitiveValues(Map values, WriterContext context) { private static boolean hasPrimitiveValues(Map<?, ?> values, WriterContext context) {
for (Object key : values.keySet()) { for (Object key : values.keySet()) {
Object fromValue = values.get(key); Object fromValue = values.get(key);
if (fromValue == null) { if (fromValue == null) {

View file

@ -34,7 +34,7 @@ class ObjectValueWriter implements ValueWriter {
return false; return false;
} }
static private Set<Field> getFieldsForClass(Class cls) { static private Set<Field> getFieldsForClass(Class<?> cls) {
Set<Field> fields = new LinkedHashSet<Field>(Arrays.asList(cls.getDeclaredFields())); Set<Field> fields = new LinkedHashSet<Field>(Arrays.asList(cls.getDeclaredFields()));
getSuperClassFields(cls.getSuperclass(), fields); getSuperClassFields(cls.getSuperclass(), fields);
@ -50,7 +50,7 @@ class ObjectValueWriter implements ValueWriter {
return prunedFields; return prunedFields;
} }
static private void getSuperClassFields(Class cls, Set<Field> fields) { static private void getSuperClassFields(Class<?> cls, Set<Field> fields) {
if (cls == Object.class) { if (cls == Object.class) {
return; return;
} }

View file

@ -13,8 +13,8 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter {
} }
@Override @Override
public void write(Object value, WriterContext context) { public void write(Object o, WriterContext context) {
Collection values = normalize(value); Collection<?> values = normalize(o);
context.write('['); context.write('[');
context.writeArrayDelimiterPadding(); context.writeArrayDelimiterPadding();
@ -22,12 +22,12 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter {
boolean first = true; boolean first = true;
ValueWriter firstWriter = null; ValueWriter firstWriter = null;
for (Object elem : values) { for (Object value : values) {
if (first) { if (first) {
firstWriter = WRITERS.findWriterFor(elem); firstWriter = WRITERS.findWriterFor(value);
first = false; first = false;
} else { } else {
ValueWriter writer = WRITERS.findWriterFor(elem); ValueWriter writer = WRITERS.findWriterFor(value);
if (writer != firstWriter) { if (writer != firstWriter) {
throw new IllegalStateException( throw new IllegalStateException(
context.getContextPath() + context.getContextPath() +
@ -38,7 +38,7 @@ class PrimitiveArrayValueWriter extends ArrayValueWriter {
context.write(", "); context.write(", ");
} }
WRITERS.write(elem, context); WRITERS.write(value, context);
} }
context.writeArrayDelimiterPadding(); context.writeArrayDelimiterPadding();

View file

@ -1,9 +1,9 @@
package com.moandjiezana.toml; package com.moandjiezana.toml;
import java.util.Collection;
import static com.moandjiezana.toml.ValueWriters.WRITERS; import static com.moandjiezana.toml.ValueWriters.WRITERS;
import java.util.Collection;
class TableArrayValueWriter extends ArrayValueWriter { class TableArrayValueWriter extends ArrayValueWriter {
static final ValueWriter TABLE_ARRAY_VALUE_WRITER = new TableArrayValueWriter(); static final ValueWriter TABLE_ARRAY_VALUE_WRITER = new TableArrayValueWriter();
@ -14,7 +14,7 @@ class TableArrayValueWriter extends ArrayValueWriter {
@Override @Override
public void write(Object value, WriterContext context) { public void write(Object value, WriterContext context) {
Collection values = normalize(value); Collection<?> values = normalize(value);
WriterContext subContext = context.pushTableFromArray(); WriterContext subContext = context.pushTableFromArray();

View file

@ -11,7 +11,6 @@ import java.util.Calendar;
import java.util.TimeZone; import java.util.TimeZone;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;