com.softicar.platform.common.code.string.LegalClassStringLiteralFilter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.code.string;
import java.util.function.Predicate;
public class LegalClassStringLiteralFilter implements Predicate {
private static final String INVALID_STRING_REGEX = ".*[\\p{L}0-9].*";
private static final String VALID_WILDCARD_REGEX = "(%s)|(%((([1-9][0-9]*)?\\\\.)?[1-9][0-9]*)?f)";
private static final String UUID_REGEX = "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}";
@Override
public boolean test(String literal) {
return literal.replaceAll(VALID_WILDCARD_REGEX, "").matches(INVALID_STRING_REGEX) && !literal.matches(UUID_REGEX);
}
}