79
79
import org .hibernate .validator .internal .util .privilegedactions .GetDeclaredMethods ;
80
80
import org .hibernate .validator .internal .util .privilegedactions .GetMethods ;
81
81
import org .hibernate .validator .internal .util .privilegedactions .NewInstance ;
82
+ import org .hibernate .validator .properties .GetterPropertyMatcher ;
82
83
import org .hibernate .validator .spi .group .DefaultGroupSequenceProvider ;
83
84
84
85
/**
@@ -98,16 +99,19 @@ public class AnnotationMetaDataProvider implements MetaDataProvider {
98
99
private final TypeResolutionHelper typeResolutionHelper ;
99
100
private final AnnotationProcessingOptions annotationProcessingOptions ;
100
101
private final ValueExtractorManager valueExtractorManager ;
102
+ private final GetterPropertyMatcher getterPropertyMatcher ;
101
103
102
104
private final BeanConfiguration <Object > objectBeanConfiguration ;
103
105
104
106
public AnnotationMetaDataProvider (ConstraintHelper constraintHelper ,
105
107
TypeResolutionHelper typeResolutionHelper ,
106
108
ValueExtractorManager valueExtractorManager ,
109
+ GetterPropertyMatcher getterPropertyMatcher ,
107
110
AnnotationProcessingOptions annotationProcessingOptions ) {
108
111
this .constraintHelper = constraintHelper ;
109
112
this .typeResolutionHelper = typeResolutionHelper ;
110
113
this .valueExtractorManager = valueExtractorManager ;
114
+ this .getterPropertyMatcher = getterPropertyMatcher ;
111
115
this .annotationProcessingOptions = annotationProcessingOptions ;
112
116
113
117
this .objectBeanConfiguration = retrieveBeanConfiguration ( Object .class );
@@ -302,7 +306,7 @@ private Set<ConstrainedExecutable> getMetaData(Executable[] executableElements)
302
306
* given element.
303
307
*/
304
308
private ConstrainedExecutable findExecutableMetaData (Executable executable ) {
305
- Callable callable = JavaBeanExecutable .of ( executable );
309
+ Callable callable = JavaBeanExecutable .of ( getterPropertyMatcher , executable );
306
310
List <ConstrainedParameter > parameterConstraints = getParameterMetaData ( executable , callable );
307
311
308
312
Map <ConstraintType , List <ConstraintDescriptorImpl <?>>> executableConstraints = findConstraints (
@@ -797,7 +801,7 @@ private Set<MetaConstraint<?>> findTypeUseConstraints(Constrainable constrainabl
797
801
*/
798
802
private <A extends Annotation > MetaConstraint <?> createTypeArgumentMetaConstraint (ConstraintDescriptorImpl <A > descriptor , TypeArgumentLocation location ,
799
803
TypeVariable <?> typeVariable , Type type ) {
800
- ConstraintLocation constraintLocation = ConstraintLocation .forTypeArgument ( location .toConstraintLocation (), typeVariable , type );
804
+ ConstraintLocation constraintLocation = ConstraintLocation .forTypeArgument ( location .toConstraintLocation ( getterPropertyMatcher ), typeVariable , type );
801
805
return MetaConstraints .create ( typeResolutionHelper , valueExtractorManager , descriptor , constraintLocation );
802
806
}
803
807
@@ -815,7 +819,7 @@ private CascadingMetaDataBuilder getCascadingMetaData(Type type, AnnotatedElemen
815
819
* which might not be possible (for instance for {@code java.util} classes).
816
820
*/
817
821
private interface TypeArgumentLocation {
818
- ConstraintLocation toConstraintLocation ();
822
+ ConstraintLocation toConstraintLocation (GetterPropertyMatcher getterPropertyMatcher );
819
823
}
820
824
821
825
private static class TypeArgumentExecutableParameterLocation implements TypeArgumentLocation {
@@ -829,8 +833,8 @@ private TypeArgumentExecutableParameterLocation(Executable executable, int index
829
833
}
830
834
831
835
@ Override
832
- public ConstraintLocation toConstraintLocation () {
833
- return ConstraintLocation .forParameter ( JavaBeanExecutable .of ( executable ), index );
836
+ public ConstraintLocation toConstraintLocation (GetterPropertyMatcher getterPropertyMatcher ) {
837
+ return ConstraintLocation .forParameter ( JavaBeanExecutable .of ( getterPropertyMatcher , executable ), index );
834
838
}
835
839
}
836
840
@@ -842,7 +846,7 @@ private TypeArgumentFieldLocation(Field field) {
842
846
}
843
847
844
848
@ Override
845
- public ConstraintLocation toConstraintLocation () {
849
+ public ConstraintLocation toConstraintLocation (GetterPropertyMatcher getterPropertyMatcher ) {
846
850
return ConstraintLocation .forProperty ( new JavaBeanField ( field ) );
847
851
}
848
852
}
@@ -855,8 +859,8 @@ private TypeArgumentReturnValueLocation(Executable executable) {
855
859
}
856
860
857
861
@ Override
858
- public ConstraintLocation toConstraintLocation () {
859
- return ConstraintLocation .forReturnValue ( JavaBeanExecutable .of ( executable ) );
862
+ public ConstraintLocation toConstraintLocation (GetterPropertyMatcher getterPropertyMatcher ) {
863
+ return ConstraintLocation .forReturnValue ( JavaBeanExecutable .of ( getterPropertyMatcher , executable ) );
860
864
}
861
865
}
862
866
@@ -872,8 +876,8 @@ private NestedTypeArgumentLocation(TypeArgumentLocation parentLocation, TypeVari
872
876
}
873
877
874
878
@ Override
875
- public ConstraintLocation toConstraintLocation () {
876
- return ConstraintLocation .forTypeArgument ( parentLocation .toConstraintLocation (), typeParameter , typeOfAnnotatedElement );
879
+ public ConstraintLocation toConstraintLocation (GetterPropertyMatcher getterPropertyMatcher ) {
880
+ return ConstraintLocation .forTypeArgument ( parentLocation .toConstraintLocation ( getterPropertyMatcher ), typeParameter , typeOfAnnotatedElement );
877
881
}
878
882
879
883
}
0 commit comments