com.buschmais.xo.neo4j.spi.helper.Converter Maven / Gradle / Ivy
package com.buschmais.xo.neo4j.spi.helper;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Converter {
private List converters;
public Converter(List converters) {
this.converters = converters;
}
public T convert(Object value) {
if (value == null) {
return null;
}
Class> valueType = value.getClass();
for (TypeConverter converter : converters) {
if (converter.getType()
.isAssignableFrom(valueType)) {
return (T) converter.convert(value);
}
}
if (value instanceof Iterable>) {
Iterable> iterable = (Iterable>) value;
List