Search in sources :

Example 16 with BiFunction

use of org.simpleflatmapper.util.BiFunction 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

Parameter (org.simpleflatmapper.reflect.Parameter)16 BiFunction (org.simpleflatmapper.util.BiFunction)16 Test (org.junit.Test)13 HashMap (java.util.HashMap)12 InstantiatorDefinition (org.simpleflatmapper.reflect.InstantiatorDefinition)11 BuilderInstantiatorDefinition (org.simpleflatmapper.reflect.BuilderInstantiatorDefinition)10 InstantiatorFactory (org.simpleflatmapper.reflect.InstantiatorFactory)10 ExecutableInstantiatorDefinition (org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition)10 ConstantBiFunction (org.simpleflatmapper.util.ConstantBiFunction)9 BuilderBiInstantiator (org.simpleflatmapper.reflect.impl.BuilderBiInstantiator)6 AsmFactory (org.simpleflatmapper.reflect.asm.AsmFactory)4 DbFinalPrimitiveObject (org.simpleflatmapper.test.beans.DbFinalPrimitiveObject)4 ConstantGetter (org.simpleflatmapper.reflect.getter.ConstantGetter)3 MappingContext (org.simpleflatmapper.map.MappingContext)2 FieldMapperColumnDefinition (org.simpleflatmapper.map.property.FieldMapperColumnDefinition)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 FieldMapper (org.simpleflatmapper.map.FieldMapper)1 MapperBuildingException (org.simpleflatmapper.map.MapperBuildingException)1 MappingContextFactoryBuilder (org.simpleflatmapper.map.context.MappingContextFactoryBuilder)1 MapperFieldMapper (org.simpleflatmapper.map.fieldmapper.MapperFieldMapper)1