org.simpleflatmapper.map.property.ConverterProperty Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-map Show documentation
Show all versions of sfm-map Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.map.property;
import org.simpleflatmapper.converter.ContextualConverter;
import org.simpleflatmapper.converter.ContextualConverterAdapter;
import org.simpleflatmapper.converter.Converter;
import org.simpleflatmapper.util.TypeHelper;
import java.lang.reflect.Type;
public class ConverterProperty {
public final ContextualConverter function;
public final Type inType;
public ConverterProperty(Converter function, Type inType) {
this.function = new ContextualConverterAdapter(function);
this.inType = inType;
}
public ConverterProperty(ContextualConverter function, Type inType) {
this.function = function;
this.inType = inType;
}
public static ConverterProperty of(ContextualConverter converter, Type inType) {
return new ConverterProperty(converter, inType);
}
public static ConverterProperty of(ContextualConverter converter) {
return new ConverterProperty(converter, getInType(converter));
}
private static Type getInType(ContextualConverter converter) {
Type[] types = TypeHelper.getGenericParameterForClass(converter.getClass(), ContextualConverter.class);
if ( types == null) {
return Object.class;
} else {
return types[0];
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy