AnnotatedElementNameUtil { @VisibleForTesting static String toHeaderName(String name) { requireNonNull(name, "name"); checkArgument(!name.isEmpty(), "name is empty."); final String upperCased = Ascii.toUpperCase(name); if (name.equals(upperCased)) { return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name); } final String lowerCased = Ascii.toLowerCase(name); if (name.equals(lowerCased)) { return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name); } if (name.indexOf('_') >= 0) { return lowerCased; } if (Ascii.isUpperCase(name.charAt(0))) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name); } else { return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name); } } private  AnnotatedElementNameUtil();   }
@Test public void ofHeaderName() { assertThat(toHeaderName("camelCase")).isEqualTo("camel-case"); assertThat(toHeaderName("CamelCase")).isEqualTo("camel-case"); assertThat(toHeaderName("snake_case")).isEqualTo("snake-case"); assertThat(toHeaderName("SNAKE_CASE")).isEqualTo("snake-case"); assertThat(toHeaderName("lowercase")).isEqualTo("lowercase"); assertThat(toHeaderName("UPPERCASE")).isEqualTo("uppercase"); assertThat(toHeaderName("What_Case")).isEqualTo("what_case"); }