![JAR search and dependency download from the Maven repository](/logo.png)
org.sfm.map.impl.FieldMapperColumnDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.map.impl;
import org.sfm.map.ColumnDefinition;
import org.sfm.map.FieldKey;
import org.sfm.map.FieldMapper;
import org.sfm.map.GetterFactory;
import org.sfm.map.column.*;
import org.sfm.reflect.Getter;
import org.sfm.reflect.meta.PropertyMeta;
import org.sfm.utils.Predicate;
import java.lang.reflect.Type;
public class FieldMapperColumnDefinition, S> extends ColumnDefinition> {
private static final FieldMapperColumnDefinition IDENTITY = new FieldMapperColumnDefinition(new ColumnProperty[0]);
public FieldMapperColumnDefinition(ColumnProperty[] properties) {
super(properties);
}
public FieldMapper, ?> getCustomFieldMapper() {
FieldMapperProperty prop = lookFor(FieldMapperProperty.class);
if (prop != null) {
return prop.getFieldMapper();
}
return null;
}
@SuppressWarnings("unchecked")
public Getter getCustomGetter() {
final GetterProperty property = lookFor(GetterProperty.class);
if (property != null) {
return (Getter) property.getGetter();
}
return null;
}
@Override
public boolean hasCustomSource() {
return has(GetterProperty.class);
}
@Override
public Type getCustomSourceReturnType() {
return lookFor(GetterProperty.class).getReturnType();
}
@SuppressWarnings("unchecked")
public GetterFactory getCustomGetterFactory(){
final GetterFactoryProperty property = lookFor(GetterFactoryProperty.class);
if (property != null) {
return (GetterFactory) property.getGetterFactory();
}
return null;
}
public boolean hasCustomFactory() {
return has(GetterFactoryProperty.class);
}
public FieldMapperColumnDefinition addGetter(Getter getter) {
return add(new GetterProperty(getter));
}
public FieldMapperColumnDefinition addGetterFactory(GetterFactory getterFactory) {
return add(new GetterFactoryProperty(getterFactory));
}
public FieldMapperColumnDefinition addFieldMapper(FieldMapper mapper){
return add(new FieldMapperProperty(mapper));
}
@SuppressWarnings("unchecked")
public static , S> FieldMapperColumnDefinition identity() {
return IDENTITY;
}
public static , S> FieldMapperColumnDefinition compose(final FieldMapperColumnDefinition def1, final FieldMapperColumnDefinition def2) {
return def1.compose(def2);
}
public static , S> FieldMapperColumnDefinition customFieldMapperDefinition(final FieldMapper mapper) {
return FieldMapperColumnDefinition.identity().addFieldMapper(mapper);
}
public static , S> FieldMapperColumnDefinition customGetter(final Getter getter) {
return FieldMapperColumnDefinition.identity().addGetter(getter);
}
public static , S> FieldMapperColumnDefinition customGetterFactory(final GetterFactory getterFactory) {
return FieldMapperColumnDefinition.identity().addGetterFactory(getterFactory);
}
public static , S> FieldMapperColumnDefinition renameDefinition(final String name) {
return FieldMapperColumnDefinition.identity().addRename(name);
}
public static , S> FieldMapperColumnDefinition ignoreDefinition() {
return FieldMapperColumnDefinition.identity().addIgnore();
}
public static , S> FieldMapperColumnDefinition key() {
return FieldMapperColumnDefinition.identity().addKey();
}
public static , S> FieldMapperColumnDefinition key(Predicate> predicate) {
return FieldMapperColumnDefinition.identity().addKey(predicate);
}
@Override
protected FieldMapperColumnDefinition newColumnDefinition(ColumnProperty[] properties) {
return new FieldMapperColumnDefinition(properties);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy