Java Code Examples for com.google.common.base.Ascii#isLowerCase()
The following examples show how to use
com.google.common.base.Ascii#isLowerCase() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JexlASTHelper.java From datawave with Apache License 2.0 | 6 votes |
/** * Rebuild the identifier with the {@link #IDENTIFIER_PREFIX} if the identifier starts with an invalid character per the Jexl IDENTIFIER definition * * @param fieldName * @param includeGroupingContext * @return */ public static String rebuildIdentifier(String fieldName, Boolean includeGroupingContext) { // fieldName may be null if it is from a Function node if (fieldName != null && fieldName.length() > 1) { if (!includeGroupingContext) { fieldName = removeGroupingContext(fieldName); } Character firstChar = fieldName.charAt(0); // Accepted first character in an identifier given the Commons-Jexl-2.1.1 IDENTIFIER definition if (!Ascii.isLowerCase(firstChar) && !Ascii.isUpperCase(firstChar) && firstChar != '_' && firstChar != '$' && firstChar != '@') { return IDENTIFIER_PREFIX + fieldName; } } return fieldName; }
Example 2
Source File: ImportRewriteDisabler.java From immutables with Apache License 2.0 | 6 votes |
private static boolean shouldDisableFor(Reporter reporter, Element element) { while (element != null) { if (element.getKind() == ElementKind.PACKAGE) { for (String segment : DOT_SPLITTER.split(((PackageElement) element).getQualifiedName())) { if (!segment.isEmpty() && Ascii.isUpperCase(segment.charAt(0))) { reporter.warning(About.INCOMPAT, WARNING_START + " uppercase package names"); return true; } } } if (element.getKind().isClass() || element.getKind().isInterface()) { if (Ascii.isLowerCase(element.getSimpleName().charAt(0))) { reporter.warning(About.INCOMPAT, WARNING_START + " lowercase class names"); return true; } } element = element.getEnclosingElement(); } return false; }
Example 3
Source File: BaseEncoding.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasLowerCase() { for (char c : chars) { if (Ascii.isLowerCase(c)) { return true; } } return false; }
Example 4
Source File: BaseEncoding.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasLowerCase() { for (char c : chars) { if (Ascii.isLowerCase(c)) { return true; } } return false; }
Example 5
Source File: BaseEncoding.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasLowerCase() { for (char c : chars) { if (Ascii.isLowerCase(c)) { return true; } } return false; }
Example 6
Source File: BaseEncoding.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasLowerCase() { for (char c : chars) { if (Ascii.isLowerCase(c)) { return true; } } return false; }
Example 7
Source File: BaseEncoding.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private boolean hasLowerCase() { for (char c : chars) { if (Ascii.isLowerCase(c)) { return true; } } return false; }
Example 8
Source File: ClassName.java From dagger2-sample with Apache License 2.0 | 5 votes |
/** * Returns a new {@link ClassName} instance for the given fully-qualified class name string. This * method assumes that the input is ASCII and follows typical Java style (lower-case package * names, upper-camel-case class names) and may produce incorrect results or throw * {@link IllegalArgumentException} otherwise. For that reason, {@link #fromClass(Class)} and * {@link #fromClass(Class)} should be preferred as they can correctly create {@link ClassName} * instances without such restrictions. */ public static ClassName bestGuessFromString(String classNameString) { checkNotNull(classNameString); List<String> parts = Splitter.on('.').splitToList(classNameString); int firstClassPartIndex = -1; for (int i = 0; i < parts.size(); i++) { String part = parts.get(i); checkArgument(SourceVersion.isIdentifier(part)); char firstChar = part.charAt(0); if (Ascii.isLowerCase(firstChar)) { // looks like a package part if (firstClassPartIndex >= 0) { throw new IllegalArgumentException("couldn't make a guess for " + classNameString); } } else if (Ascii.isUpperCase(firstChar)) { // looks like a class part if (firstClassPartIndex < 0) { firstClassPartIndex = i; } } else { throw new IllegalArgumentException("couldn't make a guess for " + classNameString); } } int lastIndex = parts.size() - 1; return new ClassName( Joiner.on('.').join(parts.subList(0, firstClassPartIndex)), firstClassPartIndex == lastIndex ? ImmutableList.<String>of() : ImmutableList.copyOf(parts.subList(firstClassPartIndex, lastIndex)), parts.get(lastIndex)); }
Example 9
Source File: Naming.java From immutables with Apache License 2.0 | 5 votes |
public String apply(String input) { if (!input.isEmpty()) { if (this == CAPITALIZED && !Ascii.isUpperCase(input.charAt(0))) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, input); } if (this == LOWERIZED && !Ascii.isLowerCase(input.charAt(0))) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, input); } } return input; }
Example 10
Source File: NullSafeAscii.java From sfs with Apache License 2.0 | 4 votes |
public static boolean isLowerCase(char c) { return Ascii.isLowerCase(c); }
Example 11
Source File: Encodings.java From immutables with Apache License 2.0 | 4 votes |
private void processMember(Element member) { if ((member.getKind() == ElementKind.FIELD || member.getKind() == ElementKind.METHOD) && !memberNames.add(memberPath(member))) { reporter.withElement(member) .error( "Duplicate member name '%s'. Encoding has limitation so that any duplicate method names are not supported," + " even when allowed by JLS: methods cannot have overloads here." + " @Encoding.Naming annotation could be used so that actually generated methods might have the same name" + " if they are not conflicting as per JLS overload rules", member.getSimpleName()); return; } if (member.getKind() == ElementKind.FIELD) { if (processField((VariableElement) member)) return; } if (member.getKind() == ElementKind.METHOD) { if (!Ascii.isLowerCase(member.getSimpleName().charAt(0))) { reporter.withElement(member) .warning("Methods not starting with lowercase ascii letter might not work properly", member.getSimpleName()); } if (processMethod((ExecutableElement) member)) return; } if (member.getKind() == ElementKind.CLASS) { if (processClass((TypeElement) member)) return; } if (member.getKind() == ElementKind.INSTANCE_INIT) { return; } if (member.getSimpleName().contentEquals("<init>")) { return; } reporter.withElement(member) .warning("Unrecognized encoding member '%s' will be ignored", member.getSimpleName()); }