final Class entity, final PropertyDescriptor[] entityPropertyDescriptors,
final Field dtoField, final List<PipeMetadata> metas, final int index, final boolean isMapOrListEntity)
throws InspectionPropertyNotFoundException, InspectionBindingNotFoundException, InspectionScanningException,
UnableToCreateInstanceException, AnnotationMissingBindingException, AnnotationValidatingBindingException, GeDARuntimeException {
final PipeMetadata meta = metas.get(index);
if (index + 1 == metas.size() || isMapOrListEntity) {
// build actual pipe for last in chain, maps or lists
// (since maps and lists do not have any nested properties, maybe another feature?)
if (meta instanceof FieldPipeMetadata) {
if (meta.getEntityFieldName().startsWith("#this#")) {
// create virtual field pipe
return VIRTUAL.build(this,
dto, entity, dtoPropertyDescriptors, entityPropertyDescriptors,
(FieldPipeMetadata) meta, null);
} else {
// create field pipe
return FIELD.build(this,
dto, entity, dtoPropertyDescriptors, entityPropertyDescriptors,
(FieldPipeMetadata) meta, null);
}
} else if (meta instanceof CollectionPipeMetadata) {
// create collection
return COLLECTION.build(this,
dto, entity, dtoPropertyDescriptors, entityPropertyDescriptors,
(CollectionPipeMetadata) meta, null);
} else if (meta instanceof MapPipeMetadata) {
// create map
return MAP.build(this,
dto, entity, dtoPropertyDescriptors, entityPropertyDescriptors,
(MapPipeMetadata) meta, null);
} else {
throw new GeDARuntimeException("Unknown pipe meta: " + meta.getClass());
}
}
final PropertyDescriptor nested = PropertyInspector.getEntityPropertyDescriptorForField(
dto, entity, meta.getDtoFieldName(), meta.getEntityFieldName(), entityPropertyDescriptors);
final PropertyDescriptor[] nestedEntityPropertyDescriptors = PropertyInspector.getPropertyDescriptorsForClassReturnedByGet(nested);
// build a chain pipe
return CHAIN.build(this, dto, entity, dtoPropertyDescriptors, entityPropertyDescriptors, meta,
createPipeChain(dto, dtoPropertyDescriptors, entity, nestedEntityPropertyDescriptors, dtoField, metas, index + 1, isMapOrListEntity)