Current behavior
In org.springframework.data.mapping.PropertyMatch, the matches(String name, Class<?> type) method currently uses String.matches(...):
if ((namePattern != null) && !name.matches(namePattern)) {
return false;
}
I noticed this while profiling application startup — PropertyMatch.matches(...) is invoked repeatedly during Spring Data repository and mapping initialization, which makes the repeated regex compilation visible in startup.
Proposed improvement
Pre-compile the namePattern in the constructor of PropertyMatch as a java.util.regex.Pattern.
Change matches(...) to use Pattern.matcher(...).matches().