33 lines
1.6 KiB
Java
33 lines
1.6 KiB
Java
package lombok.core;
|
|
|
|
import com.adjust.sdk.Constants;
|
|
import java.util.regex.Pattern;
|
|
/* loaded from: com.discord-122106.apk:lombok/core/JavaIdentifiers.SCL.lombok */
|
|
public class JavaIdentifiers {
|
|
private static final LombokImmutableList<String> KEYWORDS = LombokImmutableList.of("public", "private", "protected", "default", "switch", "case", "for", "do", "goto", "const", "strictfp", "while", "if", "else", "byte", "short", "int", Constants.LONG, "float", "double", "void", "boolean", "char", "null", "false", "true", "continue", "break", "return", "instanceof", "synchronized", "volatile", "transient", "final", "static", "interface", "class", "extends", "implements", "throws", "throw", "catch", "try", "finally", "abstract", "assert", "enum", "import", "package", "native", "new", "super", "this");
|
|
private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile("^(?:boolean|byte|short|int|long|float|double|char)$");
|
|
|
|
private JavaIdentifiers() {
|
|
}
|
|
|
|
public static boolean isValidJavaIdentifier(String str) {
|
|
if (str == null || str.isEmpty() || !Character.isJavaIdentifierStart(str.charAt(0))) {
|
|
return false;
|
|
}
|
|
for (int i = 1; i < str.length(); i++) {
|
|
if (!Character.isJavaIdentifierPart(str.charAt(i))) {
|
|
return false;
|
|
}
|
|
}
|
|
return !isKeyword(str);
|
|
}
|
|
|
|
public static boolean isKeyword(String str) {
|
|
return KEYWORDS.contains(str);
|
|
}
|
|
|
|
public static boolean isPrimitive(String str) {
|
|
return PRIMITIVE_TYPE_NAME_PATTERN.matcher(str).matches();
|
|
}
|
|
}
|