Skip to content

Commit c9d0345

Browse files
committed
HV-1363 More abstraction work around executables
1 parent 0c9d582 commit c9d0345

17 files changed

+423
-203
lines changed

engine/src/main/java/org/hibernate/validator/internal/cfg/context/ExecutableConstraintMappingContextImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private List<ConstrainedParameter> getParameters(ConstraintHelper constraintHelp
130130
new ConstrainedParameter(
131131
ConfigurationSource.API,
132132
callable,
133-
callable.getTypeOfParameter( i ),
133+
callable.getParameterGenericType( i ),
134134
i
135135
)
136136
);

engine/src/main/java/org/hibernate/validator/internal/cfg/context/ParameterConstraintMappingContextImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class ParameterConstraintMappingContextImpl
4040
ParameterConstraintMappingContextImpl(ExecutableConstraintMappingContextImpl executableContext, int parameterIndex) {
4141
super(
4242
executableContext.getTypeContext().getConstraintMapping(),
43-
executableContext.callable.getGenericParameterTypes()[parameterIndex]
43+
executableContext.callable.getParameterGenericType( parameterIndex )
4444
);
4545

4646
this.executableContext = executableContext;
@@ -121,7 +121,7 @@ public ContainerElementConstraintMappingContext containerElementType(int index,
121121

122122
public ConstrainedParameter build(ConstraintHelper constraintHelper, TypeResolutionHelper typeResolutionHelper,
123123
ValueExtractorManager valueExtractorManager) {
124-
Type parameterType = executableContext.getCallable().getTypeOfParameter( parameterIndex );
124+
Type parameterType = executableContext.getCallable().getParameterGenericType( parameterIndex );
125125

126126
return new ConstrainedParameter(
127127
ConfigurationSource.API,

engine/src/main/java/org/hibernate/validator/internal/cfg/context/TypeConstraintMappingContextImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
import org.hibernate.validator.internal.metadata.raw.ConfigurationSource;
3333
import org.hibernate.validator.internal.metadata.raw.ConstrainedElement;
3434
import org.hibernate.validator.internal.metadata.raw.ConstrainedType;
35-
import org.hibernate.validator.internal.properties.Callable;
3635
import org.hibernate.validator.internal.properties.Constrainable;
3736
import org.hibernate.validator.internal.properties.Property;
37+
import org.hibernate.validator.internal.properties.javabean.JavaBeanConstructor;
3838
import org.hibernate.validator.internal.properties.javabean.JavaBeanExecutable;
3939
import org.hibernate.validator.internal.properties.javabean.JavaBeanField;
4040
import org.hibernate.validator.internal.properties.javabean.JavaBeanGetter;
@@ -153,17 +153,17 @@ public MethodConstraintMappingContext method(String name, Class<?>... parameterT
153153
throw LOG.getBeanDoesNotContainMethodException( beanClass, name, parameterTypes );
154154
}
155155

156-
Callable callable = JavaBeanExecutable.of( method );
156+
JavaBeanExecutable<?> javaBeanExecutable = JavaBeanExecutable.of( method );
157157

158-
if ( configuredMembers.contains( callable ) ) {
158+
if ( configuredMembers.contains( javaBeanExecutable ) ) {
159159
throw LOG.getMethodHasAlreadyBeenConfiguredViaProgrammaticApiException(
160160
beanClass,
161161
ExecutableHelper.getExecutableAsString( name, parameterTypes )
162162
);
163163
}
164164

165-
MethodConstraintMappingContextImpl context = new MethodConstraintMappingContextImpl( this, callable );
166-
configuredMembers.add( callable );
165+
MethodConstraintMappingContextImpl context = new MethodConstraintMappingContextImpl( this, javaBeanExecutable );
166+
configuredMembers.add( javaBeanExecutable );
167167
executableContexts.add( context );
168168

169169
return context;
@@ -180,9 +180,9 @@ public ConstructorConstraintMappingContext constructor(Class<?>... parameterType
180180
);
181181
}
182182

183-
Callable callable = JavaBeanExecutable.of( constructor );
183+
JavaBeanConstructor javaBeanConstructor = new JavaBeanConstructor( constructor );
184184

185-
if ( configuredMembers.contains( callable ) ) {
185+
if ( configuredMembers.contains( javaBeanConstructor ) ) {
186186
throw LOG.getConstructorHasAlreadyBeConfiguredViaProgrammaticApiException(
187187
beanClass,
188188
ExecutableHelper.getExecutableAsString( beanClass.getSimpleName(), parameterTypes )
@@ -191,9 +191,9 @@ public ConstructorConstraintMappingContext constructor(Class<?>... parameterType
191191

192192
ConstructorConstraintMappingContextImpl context = new ConstructorConstraintMappingContextImpl(
193193
this,
194-
callable
194+
javaBeanConstructor
195195
);
196-
configuredMembers.add( callable );
196+
configuredMembers.add( javaBeanConstructor );
197197
executableContexts.add( context );
198198

199199
return context;

engine/src/main/java/org/hibernate/validator/internal/metadata/location/ParameterConstraintLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ParameterConstraintLocation implements ConstraintLocation {
2929
public ParameterConstraintLocation(Callable executable, int index) {
3030
this.executable = executable;
3131
this.index = index;
32-
this.typeForValidatorResolution = ReflectionHelper.boxedType( executable.getTypeOfParameter( index ) );
32+
this.typeForValidatorResolution = ReflectionHelper.boxedType( executable.getParameterGenericType( index ) );
3333
}
3434

3535
@Override

0 commit comments

Comments
 (0)