org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory 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.mapper;
import org.simpleflatmapper.map.FieldKey;
import org.simpleflatmapper.map.property.OptionalProperty;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.util.Consumer;
import java.lang.reflect.Type;
public class AbstractColumnNameDiscriminatorMapperFactory<
K extends FieldKey,
MF extends AbstractColumnNameDiscriminatorMapperFactory, S> extends AbstractMapperFactory {
private final ColumnNameGetterFactory columnNameGetterFactory;
public AbstractColumnNameDiscriminatorMapperFactory(AbstractMapperFactory config, ColumnNameGetterFactory columnNameGetterFactory) {
super(config);
this.columnNameGetterFactory = columnNameGetterFactory;
}
public AbstractColumnNameDiscriminatorMapperFactory(AbstractColumnDefinitionProvider columnDefinitions, ColumnDefinition identity, ColumnNameGetterFactory columnNameGetterFactory) {
super(columnDefinitions, identity);
this.columnNameGetterFactory = columnNameGetterFactory;
}
public MF discriminator(Class commonType, String discriminatorColumn, Consumer> consumer) {
return discriminator((Type)commonType, discriminatorColumn, consumer);
}
public MF discriminator(Type commonType, String discriminatorColumn, Consumer> consumer) {
return discriminator(commonType, discriminatorColumn, Object.class, consumer);
}
public MF discriminator(Class commonType, String discriminatorColumn, Class discriminatorType, Consumer> consumer) {
return discriminator((Type)commonType, discriminatorColumn, discriminatorType, consumer);
}
public MF discriminator(Type commonType, String discriminatorColumn, Class discriminatorType, Consumer> consumer) {
addColumnProperty(discriminatorColumn, OptionalProperty.INSTANCE);
Getter super S, ? extends V> getter = columnNameGetterFactory.getGetter(discriminatorColumn, discriminatorType);
return discriminator(commonType, getter, consumer);
}
public interface ColumnNameGetterFactory {
Getter super S, ? extends T> getGetter(String discriminatorColumn, Class discriminatorType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy