Skip to content

Commit dd51f80

Browse files
committed
fixup! HV-1363 Build abstraction over reflection in ConstraintLocation and related code
1 parent 9b26462 commit dd51f80

File tree

15 files changed

+36
-28
lines changed

15 files changed

+36
-28
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.typeOfParameter( i ),
133+
callable.getTypeOfParameter( i ),
134134
i
135135
)
136136
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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().typeOfParameter( parameterIndex );
124+
Type parameterType = executableContext.getCallable().getTypeOfParameter( parameterIndex );
125125

126126
return new ConstrainedParameter(
127127
ConfigurationSource.API,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,13 @@ protected ConstraintType getConstraintType() {
255255
}
256256

257257
/**
258-
* Returns the member with the given name and type.
258+
* Returns the property with the given name and type.
259259
*
260-
* @param clazz The class from which to retrieve the member. Cannot be {@code null}.
260+
* @param clazz The class from which to retrieve the property. Cannot be {@code null}.
261261
* @param property The property name without "is", "get" or "has". Cannot be {@code null} or empty.
262262
* @param elementType The element type. Either {@code ElementType.FIELD} or {@code ElementType METHOD}.
263263
*
264-
* @return the member which matching the name and type or {@code null} if no such member exists.
264+
* @return the property which matches the name and type or {@code null} if no such property exists.
265265
*/
266266
private Property getProperty(Class<?> clazz, String property, ElementType elementType) {
267267
Contracts.assertNotNull( clazz, MESSAGES.classCannotBeNull() );

engine/src/main/java/org/hibernate/validator/internal/engine/ConstraintViolationImpl.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public class ConstraintViolationImpl<T> implements HibernateConstraintViolation<
3939
private final Map<String, Object> messageParameters;
4040
private final Map<String, Object> expressionVariables;
4141
private final Class<T> rootBeanClass;
42-
private final ElementType elementType;
4342
private final Object[] executableParameters;
4443
private final Object executableReturnValue;
4544
private final Object dynamicPayload;
@@ -161,7 +160,6 @@ private ConstraintViolationImpl(String messageTemplate,
161160
this.leafBeanInstance = leafBeanInstance;
162161
this.constraintDescriptor = constraintDescriptor;
163162
this.rootBeanClass = rootBeanClass;
164-
this.elementType = elementType;
165163
this.executableParameters = executableParameters;
166164
this.executableReturnValue = executableReturnValue;
167165
this.dynamicPayload = dynamicPayload;
@@ -296,10 +294,6 @@ public boolean equals(Object o) {
296294
if ( constraintDescriptor != null ? !constraintDescriptor.equals( that.constraintDescriptor ) : that.constraintDescriptor != null ) {
297295
return false;
298296
}
299-
if ( elementType != null ? !elementType.equals( that.elementType ) : that.elementType != null ) {
300-
return false;
301-
}
302-
303297
return true;
304298
}
305299

@@ -331,7 +325,6 @@ private int createHashCode() {
331325
result = 31 * result + System.identityHashCode( value );
332326
result = 31 * result + ( constraintDescriptor != null ? constraintDescriptor.hashCode() : 0 );
333327
result = 31 * result + ( messageTemplate != null ? messageTemplate.hashCode() : 0 );
334-
result = 31 * result + ( elementType != null ? elementType.hashCode() : 0 );
335328
return result;
336329
}
337330
}

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.typeOfParameter( index ) );
32+
this.typeForValidatorResolution = ReflectionHelper.boxedType( executable.getTypeOfParameter( index ) );
3333
}
3434

3535
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class ReturnValueConstraintLocation implements ConstraintLocation {
2424

2525
private final Callable callable;
2626

27-
ReturnValueConstraintLocation(Callable executable) {
28-
this.callable = executable;
27+
ReturnValueConstraintLocation(Callable callable) {
28+
this.callable = callable;
2929
}
3030

3131
@Override

engine/src/main/java/org/hibernate/validator/internal/metadata/raw/ConstrainedProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.hibernate.validator.internal.properties.Property;
1414

1515
/**
16-
* Represents a property of a Java type (either field or getter) and all its associated meta-data relevant
16+
* Represents a property of a Java type (either field or getter) and all its associated metadata relevant
1717
* in the context of bean validation, for instance its constraints.
1818
*
1919
* @author Marko Bekhta

engine/src/main/java/org/hibernate/validator/internal/properties/Callable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface Callable extends Constrainable {
3232

3333
String getSignature();
3434

35-
Type typeOfParameter(int parameterIndex);
35+
Type getTypeOfParameter(int parameterIndex);
3636

3737
boolean overrides(ExecutableHelper executableHelper, Callable superTypeMethod);
3838

engine/src/main/java/org/hibernate/validator/internal/properties/Constrainable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface Constrainable {
2121

2222
Type getType();
2323

24+
@SuppressWarnings("unchecked")
2425
default <T> T as(Class<T> clazz) {
2526
return ( (T) this );
2627
}

engine/src/main/java/org/hibernate/validator/internal/properties/javabean/JavaBeanExecutable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public String getSignature() {
110110
}
111111

112112
@Override
113-
public Type typeOfParameter(int parameterIndex) {
113+
public Type getTypeOfParameter(int parameterIndex) {
114114
Type[] genericParameterTypes = executable.getGenericParameterTypes();
115115

116116
// getGenericParameterTypes() doesn't return synthetic parameters; in this case fall back to getParameterTypes()

0 commit comments

Comments
 (0)