29
29
import java .util .concurrent .locks .Lock ;
30
30
import java .util .concurrent .locks .ReentrantReadWriteLock ;
31
31
import java .util .function .Predicate ;
32
+ import java .util .regex .Pattern ;
32
33
import java .util .stream .Collectors ;
33
34
34
35
import org .apache .commons .logging .Log ;
93
94
* @author Mark Paluch
94
95
* @author Mikael Klamra
95
96
* @author Christoph Strobl
97
+ * @author Kamil Krzywański
96
98
*/
97
99
public abstract class AbstractMappingContext <E extends MutablePersistentEntity <?, P >, P extends PersistentProperty <P >>
98
100
implements MappingContext <E , P >, ApplicationEventPublisherAware , ApplicationContextAware , BeanFactoryAware ,
@@ -819,8 +821,8 @@ public boolean matches(Property property) {
819
821
*/
820
822
static class PropertyMatch {
821
823
822
- private final @ Nullable String namePattern ;
823
- private final @ Nullable String typeName ;
824
+ private final @ Nullable Pattern namePatternRegex ;
825
+ private final @ Nullable String typeName ;
824
826
825
827
/**
826
828
* Creates a new {@link PropertyMatch} for the given name pattern and type name. At least one of the parameters
@@ -833,8 +835,8 @@ public PropertyMatch(@Nullable String namePattern, @Nullable String typeName) {
833
835
834
836
Assert .isTrue (!((namePattern == null ) && (typeName == null )), "Either name pattern or type name must be given" );
835
837
836
- this .namePattern = namePattern ;
837
- this .typeName = typeName ;
838
+ this .namePatternRegex = namePattern == null ? null : Pattern . compile ( namePattern ) ;
839
+ this .typeName = typeName ;
838
840
}
839
841
840
842
/**
@@ -869,9 +871,9 @@ public boolean matches(String name, Class<?> type) {
869
871
Assert .notNull (name , "Name must not be null" );
870
872
Assert .notNull (type , "Type must not be null" );
871
873
872
- if (( namePattern != null ) && !name .matches (namePattern )) {
873
- return false ;
874
- }
874
+ if (namePatternRegex != null && !namePatternRegex . matcher ( name ) .matches ()) {
875
+ return false ;
876
+ }
875
877
876
878
if ((typeName != null ) && !type .getName ().equals (typeName )) {
877
879
return false ;
0 commit comments