Search in sources :

Example 11 with InstantiatorFactory

use of org.simpleflatmapper.reflect.InstantiatorFactory in project SimpleFlatMapper by arnaudroger.

the class ConstantSourceMapperBuilder method getConstructorFieldMappersAndInstantiator.

@SuppressWarnings("unchecked")
private InstantiatorAndFieldMappers getConstructorFieldMappersAndInstantiator() throws MapperBuildingException {
    InstantiatorFactory instantiatorFactory = reflectionService.getInstantiatorFactory();
    try {
        ConstructorInjections constructorInjections = constructorInjections();
        Map<Parameter, BiFunction<? super S, ? super MappingContext<? super S>, ?>> injections = constructorInjections.parameterGetterMap;
        MapperBiInstantiatorFactory mapperBiInstantiatorFactory = new MapperBiInstantiatorFactory(instantiatorFactory);
        GetterFactory<? super S, K> getterFactory = fieldMapperAsGetterFactory();
        BiInstantiator<S, MappingContext<? super S>, T> instantiator = mapperBiInstantiatorFactory.<S, T, K, FieldMapperColumnDefinition<K>>getBiInstantiator(mapperSource.source(), target, propertyMappingsBuilder, injections, getterFactory, reflectionService.builderIgnoresNullValues());
        return new InstantiatorAndFieldMappers(constructorInjections.fieldMappers, instantiator);
    } catch (Exception e) {
        return ErrorHelper.rethrow(e);
    }
}
Also used : FieldMapperColumnDefinition(org.simpleflatmapper.map.property.FieldMapperColumnDefinition) MapperBuildingException(org.simpleflatmapper.map.MapperBuildingException) InstantiatorFactory(org.simpleflatmapper.reflect.InstantiatorFactory) MappingContext(org.simpleflatmapper.map.MappingContext) BiFunction(org.simpleflatmapper.util.BiFunction) Parameter(org.simpleflatmapper.reflect.Parameter)

Aggregations

InstantiatorFactory (org.simpleflatmapper.reflect.InstantiatorFactory)11 HashMap (java.util.HashMap)10 InstantiatorDefinition (org.simpleflatmapper.reflect.InstantiatorDefinition)10 Parameter (org.simpleflatmapper.reflect.Parameter)10 BiFunction (org.simpleflatmapper.util.BiFunction)10 Test (org.junit.Test)9 BuilderInstantiatorDefinition (org.simpleflatmapper.reflect.BuilderInstantiatorDefinition)9 ExecutableInstantiatorDefinition (org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition)9 ConstantBiFunction (org.simpleflatmapper.util.ConstantBiFunction)9 BuilderBiInstantiator (org.simpleflatmapper.reflect.impl.BuilderBiInstantiator)6 AsmFactory (org.simpleflatmapper.reflect.asm.AsmFactory)4 MapperBuildingException (org.simpleflatmapper.map.MapperBuildingException)1 MappingContext (org.simpleflatmapper.map.MappingContext)1 FieldMapperColumnDefinition (org.simpleflatmapper.map.property.FieldMapperColumnDefinition)1 Instantiator (org.simpleflatmapper.reflect.Instantiator)1