All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleflatmapper.map.property.ConverterProperty Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
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