use of org.adempiere.util.reflect.FieldReference in project metasfresh-webui-api by metasfresh.
the class ViewColumnHelper method createClassViewColumnDescriptor.
private static ClassViewColumnDescriptor createClassViewColumnDescriptor(final Field field) {
final ViewColumn viewColumnAnn = field.getAnnotation(ViewColumn.class);
final String fieldName = !Check.isEmpty(viewColumnAnn.fieldName(), true) ? viewColumnAnn.fieldName().trim() : field.getName();
final String captionKey = !Check.isEmpty(viewColumnAnn.captionKey()) ? viewColumnAnn.captionKey() : fieldName;
final ImmutableMap<JSONViewDataType, ClassViewColumnLayoutDescriptor> layoutsByViewType = Stream.of(viewColumnAnn.layouts()).map(layoutAnn -> ClassViewColumnLayoutDescriptor.builder().viewType(layoutAnn.when()).displayed(layoutAnn.displayed()).seqNo(layoutAnn.seqNo()).build()).collect(GuavaCollectors.toImmutableMapByKey(ClassViewColumnLayoutDescriptor::getViewType));
return ClassViewColumnDescriptor.builder().fieldName(fieldName).caption(Services.get(IMsgBL.class).translatable(captionKey)).widgetType(viewColumnAnn.widgetType()).editorRenderMode(viewColumnAnn.editor()).allowSorting(viewColumnAnn.sorting()).fieldReference(FieldReference.of(field)).layoutsByViewType(layoutsByViewType).restrictToMediaTypes(ImmutableSet.copyOf(viewColumnAnn.restrictToMediaTypes())).build();
}
Aggregations