/** * Returns the given name in camel case if it is one of the know names. * This method canonicalizes also the use of {@code '_'}, {@code '-'} and {@code ' '}. * * <div class="note"><b>Rational:</b> * Axis names are not really free text. They are specified by ISO 19111 and ISO 19162. * SIS does not put restriction on axis names, but we nevertheless try to use a unique * name when we recognize it.</div> * * @param name the name in any case. * @return the given name in camel case. */ public static String toCamelCase(final String name) { return VALUES.getOrDefault(toUpperCase(name, new StringBuilder(name.length())), name); } }
/** * Tests {@link AxisNames#toCamelCase(String)}. */ @Test public void testToCamelCase() { assertEquals("Latitude", AxisNames.toCamelCase("latitude")); assertEquals("Geodetic longitude", AxisNames.toCamelCase("geodetic_longitude")); assertEquals("Ellipsoidal height", AxisNames.toCamelCase("ellipsoidal height")); assertEquals("unknown name", AxisNames.toCamelCase("unknown name")); }
/** * Tests the consistency between the constant names and their values. * * @throws IllegalAccessException should never happen. * If it happen, the {@link AxisNames} static initializer may need to be revisited. */ @Test public void testConsistency() throws IllegalAccessException { for (final Field f : AxisNames.class.getFields()) { final String name = f.getName(); assertSame(name, f.get(null), AxisNames.toCamelCase(name)); } } }
return AxisNames.toCamelCase(name);
/** * Returns the given name in camel case if it is one of the know names. * This method canonicalizes also the use of {@code '_'}, {@code '-'} and {@code ' '}. * * <div class="note"><b>Rational:</b> * Axis names are not really free text. They are specified by ISO 19111 and ISO 19162. * SIS does not put restriction on axis names, but we nevertheless try to use a unique * name when we recognize it.</div> * * @param name the name in any case. * @return the given name in camel case. */ public static String toCamelCase(final String name) { return JDK8.getOrDefault(VALUES, toUpperCase(name, new StringBuilder(name.length())), name); } }
return AxisNames.toCamelCase(name);