AbstractConverter implements Converter { protected String domainFieldName(SyntheticField[] domainFields) { StringBuilder sb = new StringBuilder(); if (domainFields.length > 0) { sb.append(domainFields[domainFields.length - 1].getName()); if (domainFields.length > 1) { sb.append(" (with path "); for (int i = 0; i < domainFields.length - 2; i++) { sb.append(domainFields[i].getName()); sb.append("."); } sb.append(domainFields[domainFields.length - 2].getName()); sb.append(")"); } } return sb.toString(); }  abstract void doConvert(Object source, Object target, String... tags); abstract String accessExceptionMessage(); abstract String argumentExceptionMessage(); @Override void convert(Object source, Object target, String... tags);  }
@Test public void testDomainFieldName() throws Exception { SyntheticField sb = new SimpleSyntheticField(SimpleExtendedDomain.class.getDeclaredField("b")); SyntheticField sc = new SimpleSyntheticField(SimpleExtendedDomain.class.getDeclaredField("c")); SyntheticField si = new SimpleSyntheticField(SimpleExtendedDomain.class.getDeclaredField("i")); assertThat(abstractConverter.domainFieldName(new SyntheticField[]{si})).isEqualTo("i"); assertThat(abstractConverter.domainFieldName(new SyntheticField[]{sc, si})).isEqualTo("i (with path c)"); assertThat(abstractConverter.domainFieldName(new SyntheticField[]{sb, sc, si})).isEqualTo("i (with path b.c)"); assertThat(abstractConverter.domainFieldName(new SyntheticField[]{})).isEqualTo(""); }