mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-29 11:42:15 +00:00
Remove warnings
This commit is contained in:
parent
47bd5022f1
commit
95e7f28cfa
6 changed files with 20 additions and 20 deletions
|
@ -28,8 +28,8 @@ abstract class ArrayValueWriter implements ValueWriter {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Collection normalize(Object value) {
|
||||
Collection collection;
|
||||
protected Collection<?> normalize(Object value) {
|
||||
Collection<Object> 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<Object>) 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();
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class ObjectValueWriter implements ValueWriter {
|
|||
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()));
|
||||
|
||||
getSuperClassFields(cls.getSuperclass(), fields);
|
||||
|
@ -50,7 +50,7 @@ class ObjectValueWriter implements ValueWriter {
|
|||
return prunedFields;
|
||||
}
|
||||
|
||||
static private void getSuperClassFields(Class cls, Set<Field> fields) {
|
||||
static private void getSuperClassFields(Class<?> cls, Set<Field> fields) {
|
||||
if (cls == Object.class) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue