StringCase (String str) { ThreeState hasLower = ThreeState.NO, hasUpper = ThreeState.NO; for (int i = 0; i < str.length(); ) { int codepoint = str.codePointAt(i); if (Character.isLowerCase(codepoint)) { hasLower = ThreeState.YES; if (hasUpper == ThreeState.YES) break; } else if (Character.isUpperCase(codepoint)) { hasUpper = ThreeState.YES; if (hasLower == ThreeState.YES) break; } i += Character.charCount(codepoint); } return new StringCase(hasLower, hasUpper); }