2929import java .util .concurrent .locks .Lock ;
3030import java .util .concurrent .locks .ReentrantReadWriteLock ;
3131import java .util .function .Predicate ;
32+ import java .util .regex .Pattern ;
3233import java .util .stream .Collectors ;
3334
3435import org .apache .commons .logging .Log ;
9394 * @author Mark Paluch
9495 * @author Mikael Klamra
9596 * @author Christoph Strobl
97+ * @author Kamil Krzywański
9698 */
9799public abstract class AbstractMappingContext <E extends MutablePersistentEntity <?, P >, P extends PersistentProperty <P >>
98100 implements MappingContext <E , P >, ApplicationEventPublisherAware , ApplicationContextAware , BeanFactoryAware ,
@@ -812,8 +814,8 @@ public boolean matches(Property property) {
812814 */
813815 static class PropertyMatch {
814816
815- private final @ Nullable String namePattern ;
816- private final @ Nullable String typeName ;
817+ private final @ Nullable Pattern namePatternRegex ;
818+ private final @ Nullable String typeName ;
817819
818820 /**
819821 * 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) {
826828
827829 Assert .isTrue (!((namePattern == null ) && (typeName == null )), "Either name pattern or type name must be given" );
828830
829- this .namePattern = namePattern ;
830- this .typeName = typeName ;
831+ this .namePatternRegex = namePattern == null ? null : Pattern . compile ( namePattern ) ;
832+ this .typeName = typeName ;
831833 }
832834
833835 /**
@@ -862,9 +864,9 @@ public boolean matches(String name, Class<?> type) {
862864 Assert .notNull (name , "Name must not be null" );
863865 Assert .notNull (type , "Type must not be null" );
864866
865- if (( namePattern != null ) && !name .matches (namePattern )) {
866- return false ;
867- }
867+ if (namePatternRegex != null && !namePatternRegex . matcher ( name ) .matches ()) {
868+ return false ;
869+ }
868870
869871 if ((typeName != null ) && !type .getName ().equals (typeName )) {
870872 return false ;
0 commit comments