MiscUtil { static private boolean ignoreFirstUnderscore(String value) { if (value.length() > 3 && isSeparator(value.charAt(0)) && !isSeparator(value.charAt(1)) && !isSeparator(value.charAt(2))) { return true; } else { return false; } }  static String toVar(String name); static String toName(String name); static String toReadablePluralLabel(String value); static String toReadableLabel(String value); static boolean endsWithIgnoreCase(String name, Iterable<String> patterns); static boolean startsWithIgnoreCase(String name, Iterable<String> patterns); static boolean contains(String name, Iterable<String> patterns); static boolean equalsIgnoreCase(String name, Iterable<String> patterns); static boolean isUniCase(String value); static boolean isWithinAnUnderscorePatternButIsNotJavaBeanSpecificCase(String value, int position);  }
@Test public void ignoreFirstUnderscore() { assertThat(toName("_toto")).isEqualTo("Toto"); assertThat(toName("_Toto")).isEqualTo("Toto"); assertThat(toName("_To_to")).isEqualTo("ToTo"); assertThat(toName("_To__to")).isEqualTo("To_To"); assertThat(toVar("_toto")).isEqualTo("toto"); assertThat(toVar("_Toto")).isEqualTo("toto"); assertThat(toVar("_To_to")).isEqualTo("toTo"); assertThat(toVar("_To__to")).isEqualTo("to_To"); assertThat(toName("-toto")).isEqualTo("Toto"); assertThat(toName("-Toto")).isEqualTo("Toto"); assertThat(toName("-To-to")).isEqualTo("ToTo"); assertThat(toName("-To--to")).isEqualTo("To_To"); assertThat(toVar("-toto")).isEqualTo("toto"); assertThat(toVar("-Toto")).isEqualTo("toto"); assertThat(toVar("-To-to")).isEqualTo("toTo"); assertThat(toVar("-To--to")).isEqualTo("to_To"); }