
org.sfm.map.impl.MapperConfig Maven / Gradle / Ivy
package org.sfm.map.impl;
import org.sfm.map.*;
import org.sfm.reflect.meta.PropertyNameMatcherFactory;
import static org.sfm.utils.Asserts.requireNonNull;
public final class MapperConfig, CD extends ColumnDefinition> {
public static final int NO_ASM_MAPPER_THRESHOLD = 792; // see https://github.com/arnaudroger/SimpleFlatMapper/issues/152
public static final int MAX_METHOD_SIZE = 128;
public static > MapperConfig> fieldMapperConfig() {
return new MapperConfig>(
new IdentityFieldMapperColumnDefinitionProvider(),
new DefaultPropertyNameMatcherFactory(),
new RethrowMapperBuilderErrorHandler(),
false,
NO_ASM_MAPPER_THRESHOLD,
new RethrowFieldMapperErrorHandler(),
new RethrowRowHandlerErrorHandler(), MAX_METHOD_SIZE);
}
public static , CD extends ColumnDefinition> MapperConfig config(ColumnDefinitionProvider columnDefinitionProvider) {
return new MapperConfig(
columnDefinitionProvider,
new DefaultPropertyNameMatcherFactory(),
new RethrowMapperBuilderErrorHandler(),
false,
NO_ASM_MAPPER_THRESHOLD,
new RethrowFieldMapperErrorHandler(),
new RethrowRowHandlerErrorHandler(), MAX_METHOD_SIZE);
}
private final ColumnDefinitionProvider columnDefinitions;
private final PropertyNameMatcherFactory propertyNameMatcherFactory;
private final MapperBuilderErrorHandler mapperBuilderErrorHandler;
private final boolean failOnAsm;
private final int asmMapperNbFieldsLimit;
private final FieldMapperErrorHandler fieldMapperErrorHandler;
private final RowHandlerErrorHandler rowHandlerErrorHandler;
private final int maxMethodSize;
private MapperConfig(
ColumnDefinitionProvider columnDefinitions,
PropertyNameMatcherFactory propertyNameMatcherFactory,
MapperBuilderErrorHandler mapperBuilderErrorHandler,
boolean failOnAsm,
int asmMapperNbFieldsLimit,
FieldMapperErrorHandler fieldMapperErrorHandler,
RowHandlerErrorHandler rowHandlerErrorHandler, int maxMethodSize) {
this.columnDefinitions = columnDefinitions;
this.propertyNameMatcherFactory = propertyNameMatcherFactory;
this.mapperBuilderErrorHandler = mapperBuilderErrorHandler;
this.failOnAsm = failOnAsm;
this.asmMapperNbFieldsLimit = asmMapperNbFieldsLimit;
this.fieldMapperErrorHandler = fieldMapperErrorHandler;
this.rowHandlerErrorHandler = rowHandlerErrorHandler;
this.maxMethodSize = maxMethodSize;
}
public ColumnDefinitionProvider columnDefinitions() {
return columnDefinitions;
}
public PropertyNameMatcherFactory propertyNameMatcherFactory() {
return propertyNameMatcherFactory;
}
public MapperBuilderErrorHandler mapperBuilderErrorHandler() {
return mapperBuilderErrorHandler;
}
public boolean failOnAsm() {
return failOnAsm;
}
public int asmMapperNbFieldsLimit() {
return asmMapperNbFieldsLimit;
}
public > MapperConfig columnDefinitions(ColumnDefinitionProvider columnDefinitions) {
requireNonNull("columnDefinitions", columnDefinitions);
return
new MapperConfig(
columnDefinitions,
propertyNameMatcherFactory,
mapperBuilderErrorHandler,
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler, maxMethodSize);
}
public MapperConfig propertyNameMatcherFactory(PropertyNameMatcherFactory propertyNameMatcherFactory) {
return new MapperConfig(
columnDefinitions,
requireNonNull("propertyNameMatcherFactory", propertyNameMatcherFactory),
mapperBuilderErrorHandler,
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler, maxMethodSize);
}
public MapperConfig mapperBuilderErrorHandler(MapperBuilderErrorHandler mapperBuilderErrorHandler) {
return new MapperConfig(
columnDefinitions,
propertyNameMatcherFactory,
requireNonNull("mapperBuilderErrorHandler", mapperBuilderErrorHandler),
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler, maxMethodSize);
}
public MapperConfig failOnAsm(boolean failOnAsm) {
return new MapperConfig(
columnDefinitions,
propertyNameMatcherFactory,
mapperBuilderErrorHandler,
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler, maxMethodSize);
}
public MapperConfig asmMapperNbFieldsLimit(int asmMapperNbFieldsLimit) {
return new MapperConfig(
columnDefinitions,
propertyNameMatcherFactory,
mapperBuilderErrorHandler,
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler, maxMethodSize);
}
public MapperConfig fieldMapperErrorHandler(FieldMapperErrorHandler fieldMapperErrorHandler) {
return new MapperConfig(
columnDefinitions,
propertyNameMatcherFactory,
mapperBuilderErrorHandler,
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler, maxMethodSize);
}
public MapperConfig rowHandlerErrorHandler(RowHandlerErrorHandler rowHandlerErrorHandler) {
return new MapperConfig(
columnDefinitions,
propertyNameMatcherFactory,
mapperBuilderErrorHandler,
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler,
maxMethodSize);
}
public RowHandlerErrorHandler rowHandlerErrorHandler() {
return rowHandlerErrorHandler;
}
public boolean hasFieldMapperErrorHandler() {
return fieldMapperErrorHandler != null
&& !(fieldMapperErrorHandler instanceof RethrowFieldMapperErrorHandler);
}
public FieldMapperErrorHandler fieldMapperErrorHandler() {
return fieldMapperErrorHandler;
}
public int maxMethodSize() {
return maxMethodSize;
}
public MapperConfig maxMethodSize(int maxMethodSize) {
return new MapperConfig(
columnDefinitions,
propertyNameMatcherFactory,
mapperBuilderErrorHandler,
failOnAsm,
asmMapperNbFieldsLimit,
fieldMapperErrorHandler,
rowHandlerErrorHandler,
maxMethodSize);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy