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

org.simpleflatmapper.csv.property.CustomReaderProperty Maven / Gradle / Ivy

Go to download

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

The newest version!
package org.simpleflatmapper.csv.property;


import org.simpleflatmapper.csv.CellValueReader;
import org.simpleflatmapper.csv.impl.CellValueReaderToStringReaderAdapter;
import org.simpleflatmapper.lightningcsv.StringReader;
import org.simpleflatmapper.util.TypeHelper;

import java.lang.reflect.Type;

import static org.simpleflatmapper.util.Asserts.requireNonNull;

public class CustomReaderProperty {
    private final CellValueReader reader;
    
    public  CustomReaderProperty(StringReader reader) {
        this.reader = new CellValueReaderToStringReaderAdapter(requireNonNull("reader",reader));
    }
    public CustomReaderProperty(CellValueReader reader) {
        this.reader = requireNonNull("reader",reader);
    }

    public CellValueReader getReader() {
        return reader;
    }

    public Type getReturnType() {
        final Type[] paramTypesForInterface = TypeHelper.getGenericParameterForClass(reader.getClass(), CellValueReader.class);
        return paramTypesForInterface != null ? paramTypesForInterface[0] : null;
    }


    @Override
    public String toString() {
        return "CustomReader{CellValueReader}";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy