List of usage examples for javax.lang.model SourceVersion isKeyword
public static boolean isKeyword(CharSequence s)
From source file:com.mastfrog.parameters.processor.Processor.java
static boolean isJavaIdentifier(String id) { if (id == null) { return false; }//from ww w.ja v a 2 s. c o m return SourceVersion.isIdentifier(id) && !SourceVersion.isKeyword(id); }
From source file:org.bonitasoft.engine.bdm.CodeGenerator.java
private void validateFieldName(final String fieldName) { if (fieldName == null || fieldName.isEmpty()) { throw new IllegalArgumentException("Field name cannot be null or empty"); }/* w ww .j a v a 2 s . c o m*/ if (SourceVersion.isKeyword(fieldName)) { throw new IllegalArgumentException("Field " + fieldName + " is a resered keyword"); } if (!SourceVersion.isIdentifier(fieldName)) { throw new IllegalArgumentException("Field " + fieldName + " is not a valid Java identifier"); } }
From source file:org.guvnor.common.services.backend.validation.ValidationUtils.java
public static boolean isJavaIdentifier(final String value) { if (StringUtils.isBlank(value)) { return false; }// www .j av a2 s.co m if (!SourceVersion.isIdentifier(value) || SourceVersion.isKeyword(value)) { return false; } for (int i = 0; i < value.length(); i++) { if (!CharUtils.isAsciiPrintable(value.charAt(i))) { return false; } } return true; }