@Test public void testName() { final Citation citation = Citations.EPSG; final PropertyAccessor accessor = createPropertyAccessor(citation); assertEquals("Non-existent property", -1, accessor.indexOf("dummy")); assertEquals("getTitle() property", "title", accessor.name(accessor.indexOf("title"))); assertEquals("getTitle() property", "title", accessor.name(accessor.indexOf("TITLE"))); assertEquals("getISBN() property", "ISBN", accessor.name(accessor.indexOf("ISBN"))); assertNull(accessor.name(-1)); }
final String name(final int index) { if (index >= 0 && index < getters.length) { String name = getters[index].getName(); final int base = prefix(name).length(); if (name.length() > base) { if (isAcronym(name, base)) { name = name.substring(base); } else { final char up = name.charAt(base); final char lo = Character.toLowerCase(up); if (up != lo) { name = lo + name.substring(base + 1); } else { name = name.substring(base); } } } return name; } return null; }
PropertyAccessor { final String name(final int index) { if (index >= 0 && index < getters.length) { String name = getters[index].getName(); final int base = prefix(name).length(); if (name.length() > base) { if (isAcronym(name, base)) { name = name.substring(base); } else { final char up = name.charAt(base); final char lo = Character.toLowerCase(up); if (up != lo) { name = lo + name.substring(base + 1); } else { name = name.substring(base); } } } return name; } return null; } }
PropertyAccessor { final String name(final int index) { if (index >= 0 && index < getters.length) { String name = getters[index].getName(); final int base = prefix(name).length(); if (name.length() > base) { if (isAcronym(name, base)) { name = name.substring(base); } else { final char up = name.charAt(base); final char lo = Character.toLowerCase(up); if (up != lo) { name = lo + name.substring(base + 1); } else { name = name.substring(base); } } } return name; } return null; } PropertyAccessor(final Class<?> implementation, final Class<?> type); }
PropertyAccessor { final String name(final int index) { if (index >= 0 && index < getters.length) { String name = getters[index].getName(); final int base = prefix(name).length(); if (name.length() > base) { if (isAcronym(name, base)) { name = name.substring(base); } else { final char up = name.charAt(base); final char lo = Character.toLowerCase(up); if (up != lo) { name = lo + name.substring(base + 1); } else { name = name.substring(base); } } } return name; } return null; } PropertyAccessor(final Class<?> implementation, final Class<?> type); boolean shallowEquals(final Object metadata1, final Object metadata2, final boolean skipNulls); boolean shallowCopy(final Object source, final Object target, final boolean skipNulls); int hashCode(final Object metadata); int count(final Object metadata, final int max); }
PropertyAccessor { final String name(final int index) { if (index >= 0 && index < getters.length) { String name = getters[index].getName(); final int base = prefix(name).length(); if (name.length() > base) { if (isAcronym(name, base)) { name = name.substring(base); } else { final char up = name.charAt(base); final char lo = Character.toLowerCase(up); if (up != lo) { name = lo + name.substring(base + 1); } else { name = name.substring(base); } } } return name; } return null; } PropertyAccessor(final Class<?> implementation, final Class<?> type); boolean shallowEquals(final Object metadata1, final Object metadata2, final boolean skipNulls); boolean shallowCopy(final Object source, final Object target, final boolean skipNulls); int hashCode(final Object metadata); int count(final Object metadata, final int max);  }