use of org.simpleflatmapper.reflect.getter.GetterWithConverter in project SimpleFlatMapper by arnaudroger.
the class ConstantSourceFieldMapperFactoryImpl method lookForAlternativeGetter.
private <P, J> Getter<? super S, ? extends P> lookForAlternativeGetter(ClassMeta<P> classMeta, K key, FieldMapperColumnDefinition<K> columnDefinition, Collection<Type> types) {
// look for converter
Type propertyType = classMeta.getType();
Type sourceType = key.getType(propertyType);
Object[] properties = columnDefinition.properties();
Converter<? super J, ? extends P> converter = converterService.findConverter(sourceType, propertyType, properties);
if (converter != null) {
Getter<? super S, ? extends J> getter = getterFactory.newGetter(sourceType, key, properties);
return new GetterWithConverter<S, J, P>(converter, getter);
}
return lookForInstantiatorGetter(classMeta, key, columnDefinition, types);
}
use of org.simpleflatmapper.reflect.getter.GetterWithConverter 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