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 ,
@@ -812,8 +814,8 @@ public boolean matches(Property property) {
812
814
*/
813
815
static class PropertyMatch {
814
816
815
- private final @ Nullable String namePattern ;
816
- private final @ Nullable String typeName ;
817
+ private final @ Nullable Pattern namePatternRegex ;
818
+ private final @ Nullable String typeName ;
817
819
818
820
/**
819
821
* Creates a new {@link PropertyMatch} for the given name pattern and type name. At least one of the parameters
@@ -826,8 +828,8 @@ public PropertyMatch(@Nullable String namePattern, @Nullable String typeName) {
826
828
827
829
Assert .isTrue (!((namePattern == null ) && (typeName == null )), "Either name pattern or type name must be given" );
828
830
829
- this .namePattern = namePattern ;
830
- this .typeName = typeName ;
831
+ this .namePatternRegex = namePattern == null ? null : Pattern . compile ( namePattern ) ;
832
+ this .typeName = typeName ;
831
833
}
832
834
833
835
/**
@@ -862,9 +864,9 @@ public boolean matches(String name, Class<?> type) {
862
864
Assert .notNull (name , "Name must not be null" );
863
865
Assert .notNull (type , "Type must not be null" );
864
866
865
- if (( namePattern != null ) && !name .matches (namePattern )) {
866
- return false ;
867
- }
867
+ if (namePatternRegex != null && !namePatternRegex . matcher ( name ) .matches ()) {
868
+ return false ;
869
+ }
868
870
869
871
if ((typeName != null ) && !type .getName ().equals (typeName )) {
870
872
return false ;
0 commit comments