MCPcopy Create free account
hub / github.com/antlr/codebuff / CaseFormat

Enum CaseFormat

output/java_guava/1.4.19/CaseFormat.java:32–234  ·  view source on GitHub ↗

Utility class for converting between various ASCII case formats. Behavior is undefined for non-ASCII input. @author Mike Bostock @since 1.0

Source from the content-addressed store, hash-verified

30
31
32@GwtCompatible
33public enum CaseFormat {
34 /**
35 * Hyphenated variable naming convention, e.g., "lower-hyphen".
36 */
37 LOWER_HYPHEN(CharMatcher.is('-'), "-") {
38 @Override
39 String normalizeWord(String word) {
40 return Ascii.toLowerCase(word);
41 }
42
43 @Override
44 String convert(CaseFormat format, String s) {
45 if (format == LOWER_UNDERSCORE) {
46 return s.replace('-', '_');
47 }
48 if (format == UPPER_UNDERSCORE) {
49 return Ascii.toUpperCase(s.replace('-', '_'));
50 }
51 return super.convert(format, s);
52 }
53 },
54
55 /**
56 * C++ variable naming convention, e.g., "lower_underscore".
57 */
58 LOWER_UNDERSCORE(CharMatcher.is('_'), "_") {
59 @Override
60 String normalizeWord(String word) {
61 return Ascii.toLowerCase(word);
62 }
63
64 @Override
65 String convert(CaseFormat format, String s) {
66 if (format == LOWER_HYPHEN) {
67 return s.replace('_', '-');
68 }
69 if (format == UPPER_UNDERSCORE) {
70 return Ascii.toUpperCase(s);
71 }
72 return super.convert(format, s);
73 }
74 },
75
76 /**
77 * Java variable naming convention, e.g., "lowerCamel".
78 */
79 LOWER_CAMEL(CharMatcher.inRange('A', 'Z'), "") {
80 @Override
81 String normalizeWord(String word) {
82 return firstCharOnlyToUpper(word);
83 }
84 },
85
86 /**
87 * Java and C++ class naming convention, e.g., "UpperCamel".
88 */
89 UPPER_CAMEL(CharMatcher.inRange('A', 'Z'), "") {

Callers

nothing calls this directly

Calls 2

isMethod · 0.95
inRangeMethod · 0.95

Tested by

no test coverage detected