com.moandjiezana.toml.ArrayValueWriter Maven / Gradle / Ivy
package com.moandjiezana.toml;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import static com.moandjiezana.toml.ValueWriters.WRITERS;
abstract class ArrayValueWriter implements ValueWriter {
static protected boolean isArrayish(Object value) {
return value instanceof Collection || value.getClass().isArray();
}
@Override
public boolean isPrimitiveType() {
return false;
}
static boolean isArrayOfPrimitive(Object array) {
Object first = peek(array);
if (first != null) {
ValueWriter valueWriter = WRITERS.findWriterFor(first);
return valueWriter.isPrimitiveType() || isArrayish(first);
}
return true;
}
@SuppressWarnings("unchecked")
protected Collection> normalize(Object value) {
Collection