@Test public void shouldFormatRelationships() { for (Class clazz : asList(OneToOneRelationship.class, ManyToOneRelationship.class)) { FieldDto relField = FieldTestHelper.fieldDto("name", clazz); assertEquals("something", exportCustomizer.formatField(relField, new UIRepresentationTestClass(1, "something"))); assertEquals("something", exportCustomizer.formatField(relField, new ToStringTestClass(1, "something"))); assertEquals("4", exportCustomizer.formatField(relField, new NoToString(4))); assertEquals("", exportCustomizer.formatField(relField, null)); } for (Class clazz : asList(OneToManyRelationship.class, ManyToManyRelationship.class)) { FieldDto relField = FieldTestHelper.fieldDto("name", clazz); assertEquals("first,second", exportCustomizer.formatField(relField, asList( new UIRepresentationTestClass(1, "first"), new UIRepresentationTestClass(2, "second")))); assertEquals("first,second", exportCustomizer.formatField(relField, asList( new ToStringTestClass(1, "first"), new ToStringTestClass(2, "second")))); assertEquals("7,8", exportCustomizer.formatField(relField, asList( new NoToString(7), new NoToString(8)))); assertEquals("", exportCustomizer.formatField(relField, null)); assertEquals("", exportCustomizer.formatField(relField, Collections.emptySet())); } }
@Override public String formatField(FieldDto fieldDto, Object object) { Object displayValue = DisplayHelper.getDisplayValueForField(fieldDto, object); if (displayValue == null) { displayValue = object; } else if (displayValue instanceof Map) { Map asMap = (Map) displayValue; displayValue = asMap.values(); } return TypeHelper.format(displayValue, COLL_JOIN_CHAR); }
DefaultCsvExportCustomizer implements CsvExportCustomizer { @Override public String formatField(FieldDto fieldDto, Object object) { Object displayValue = DisplayHelper.getDisplayValueForField(fieldDto, object); if (displayValue == null) { displayValue = object; } else if (displayValue instanceof Map) { Map asMap = (Map) displayValue; displayValue = asMap.values(); } return TypeHelper.format(displayValue, COLL_JOIN_CHAR); } }
DefaultCsvExportCustomizer implements CsvExportCustomizer { @Override public String formatField(FieldDto fieldDto, Object object) { Object displayValue = DisplayHelper.getDisplayValueForField(fieldDto, object); if (displayValue == null) { displayValue = object; } else if (displayValue instanceof Map) { Map asMap = (Map) displayValue; displayValue = asMap.values(); } return TypeHelper.format(displayValue, COLL_JOIN_CHAR); }  }
DefaultCsvExportCustomizer implements CsvExportCustomizer { @Override public String formatField(FieldDto fieldDto, Object object) { Object displayValue = DisplayHelper.getDisplayValueForField(fieldDto, object); if (displayValue == null) { displayValue = object; } else if (displayValue instanceof Map) { Map asMap = (Map) displayValue; displayValue = asMap.values(); } return TypeHelper.format(displayValue, COLL_JOIN_CHAR); }  @Override String formatField(FieldDto fieldDto, Object object); @Override Comparator<FieldDto> columnOrderComparator(BrowsingSettingsDto browsingSettingsDto); @Override String exportDisplayName(FieldDto fieldDto); }
DefaultCsvExportCustomizer implements CsvExportCustomizer { @Override public String formatField(FieldDto fieldDto, Object object) { Object displayValue = DisplayHelper.getDisplayValueForField(fieldDto, object); if (displayValue == null) { displayValue = object; } else if (displayValue instanceof Map) { Map asMap = (Map) displayValue; displayValue = asMap.values(); } return TypeHelper.format(displayValue, COLL_JOIN_CHAR); }  @Override String formatField(FieldDto fieldDto, Object object); @Override Comparator<FieldDto> columnOrderComparator(BrowsingSettingsDto browsingSettingsDto); @Override String exportDisplayName(FieldDto fieldDto);  }