org.simpleflatmapper.poi.SheetMapperFactory Maven / Gradle / Ivy
The newest version!
package org.simpleflatmapper.poi;
import org.apache.poi.ss.usermodel.Row;
import org.simpleflatmapper.map.getter.ContextualGetterFactoryAdapter;
import org.simpleflatmapper.map.mapper.AbstractMapperFactory;
import org.simpleflatmapper.map.property.FieldMapperColumnDefinition;
import org.simpleflatmapper.map.mapper.FieldMapperColumnDefinitionProviderImpl;
import org.simpleflatmapper.map.MapperConfig;
import org.simpleflatmapper.poi.impl.DynamicSheetMapper;
import org.simpleflatmapper.reflect.getter.GetterFactory;
import org.simpleflatmapper.poi.impl.RowGetterFactory;
import org.simpleflatmapper.util.TypeReference;
import org.simpleflatmapper.reflect.meta.ClassMeta;
import org.simpleflatmapper.csv.CsvColumnKey;
import java.lang.reflect.Type;
public class SheetMapperFactory extends AbstractMapperFactory {
private SheetMapperFactory(AbstractMapperFactory config) {
super(config);
}
/**
*
* @return new newInstance of factory
*/
public static SheetMapperFactory newInstance() {
return new SheetMapperFactory();
}
public static SheetMapperFactory newInstance(AbstractMapperFactory config) {
return new SheetMapperFactory(config);
}
private SheetMapperFactory() {
super(new FieldMapperColumnDefinitionProviderImpl(), FieldMapperColumnDefinition.identity(), new ContextualGetterFactoryAdapter(new RowGetterFactory()));
}
/**
* set a new getterFactory.
* @param getterFactory the getterFactory
* @return the newInstance
*/
public SheetMapperFactory getterFactory(GetterFactory getterFactory) {
return super.addGetterFactory(new ContextualGetterFactoryAdapter(getterFactory));
}
/**
*
* @param type the type to map
* @param the type to map
* @return a builder on the specified type
*/
public SheetMapperBuilder newBuilder(Class type) {
return newBuilder((Type)type);
}
/**
*
* @param type the type to map
* @param the type to map
* @return a builder on the specified type
*/
public SheetMapperBuilder newBuilder(TypeReference type) {
return newBuilder(type.getType());
}
/**
*
* @param type the type to map
* @param the type to map
* @return a builder on the specified type
*/
public SheetMapperBuilder newBuilder(Type type) {
MapperConfig mapperConfig = mapperConfig(type);
ClassMeta classMeta = getClassMeta(type);
return new SheetMapperBuilder(classMeta, mapperConfig, getterFactory);
}
/**
*
* @param type the type to map
* @param the type to map
* @return a dynamic mapper on the specified type
*/
public SheetMapper newMapper(Class type) {
return newMapper((Type)type);
}
/**
*
* @param type the type to map
* @param the type to map
* @return a dynamic mapper on the specified type
*/
public SheetMapper newMapper(TypeReference type) {
return newMapper(type.getType());
}
/**
*
* @param type the type to map
* @param the type to map
* @return a dynamic mapper on the specified type
*/
public SheetMapper newMapper(Type type) {
ClassMeta classMeta = getClassMeta(type);
MapperConfig mapperConfig = mapperConfig(type);
return new DynamicSheetMapper(classMeta, mapperConfig, getterFactory);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy