use of org.simpleflatmapper.reflect.getter.InstantiatorGetter in project SimpleFlatMapper by arnaudroger.
the class ConstantSourceFieldMapperFactoryImpl method getGettetInstantiator.
private <T, P> Getter<? super S, ? extends P> getGettetInstantiator(ClassMeta<P> classMeta, InstantiatorDefinition id, K key, FieldMapperColumnDefinition<K> columnDefinition, Collection<Type> types) {
Instantiator<? super T, ? extends P> instantiator = classMeta.getReflectionService().getInstantiatorFactory().getOneArgIdentityInstantiator(id, classMeta.getReflectionService().builderIgnoresNullValues());
final Type paramType = id.getParameters()[0].getGenericType();
Getter<? super S, ? extends T> subGetter = getterFactory.newGetter(paramType, key, columnDefinition);
if (subGetter == null) {
if (types.contains(paramType)) {
// loop circuit cutter
return null;
}
types.add(paramType);
// converter?
Type sourceType = key.getType(paramType);
Converter converter = converterService.findConverter(sourceType, paramType, columnDefinition.properties());
if (converter != null) {
Getter sourceTypeGetter = getterFactory.newGetter(sourceType, key, columnDefinition);
subGetter = new GetterWithConverter(converter, sourceTypeGetter);
} else {
subGetter = lookForInstantiatorGetter(classMeta.getReflectionService().<T>getClassMeta(paramType), key, columnDefinition, types);
}
}
if (subGetter != null) {
return new InstantiatorGetter<T, S, P>(instantiator, subGetter);
} else
return null;
}
Aggregations