WordCase (String word) { boolean upperCase = true; boolean lowerCase = true; boolean capitalized = true; for (int i = 0, length = word.length(); i < length; i++) { final char c = word.charAt(i); if (Character.isLetter(c)) { // assume no digit at the start of identifier final boolean u = Character.isUpperCase(c); final boolean l = Character.isLowerCase(c); if (upperCase && lowerCase) { capitalized = u; } upperCase &= u; lowerCase &= l; } } return new WordCase(upperCase, lowerCase, capitalized); }