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

Enum CaseFormat

corpus/java/training/guava/base/CaseFormat.java:33–228  ·  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

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