Skip to content

Commit dbffeba

Browse files
marko-bekhtagsmet
authored andcommitted
HV-1623 Remove redundant check in ConfiguredConstraint
- based on the usage of the method we cannot receive methods into it, hence the check can be removed. And also the method can be named more specific to represent what it is really should be doing.
1 parent 556d277 commit dbffeba

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import org.hibernate.validator.cfg.ConstraintDef;
2222
import org.hibernate.validator.internal.metadata.location.ConstraintLocation;
2323
import org.hibernate.validator.internal.properties.Callable;
24-
import org.hibernate.validator.internal.properties.Property;
2524
import org.hibernate.validator.internal.properties.javabean.JavaBeanField;
26-
import org.hibernate.validator.internal.properties.javabean.JavaBeanGetter;
2725
import org.hibernate.validator.internal.util.annotation.AnnotationDescriptor;
2826
import org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor;
2927
import org.hibernate.validator.internal.util.logging.Log;
@@ -57,13 +55,11 @@ static <A extends Annotation> ConfiguredConstraint<A> forType(ConstraintDef<?, A
5755
return new ConfiguredConstraint<>( constraint, ConstraintLocation.forClass( beanType ), ElementType.TYPE );
5856
}
5957

60-
static <A extends Annotation> ConfiguredConstraint<A> forProperty(ConstraintDef<?, A> constraint, Property property) {
58+
static <A extends Annotation> ConfiguredConstraint<A> forFieldProperty(ConstraintDef<?, A> constraint, JavaBeanField javaBeanField) {
6159
return new ConfiguredConstraint<>(
6260
constraint,
63-
property instanceof JavaBeanField
64-
? ConstraintLocation.forField( property.as( JavaBeanField.class ) )
65-
: ConstraintLocation.forGetter( property.as( JavaBeanGetter.class ) ),
66-
property instanceof JavaBeanField ? ElementType.FIELD : ElementType.METHOD
61+
ConstraintLocation.forField( javaBeanField ),
62+
ElementType.FIELD
6763
);
6864
}
6965

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ protected PropertyConstraintMappingContextImpl getThis() {
6262
public PropertyConstraintMappingContext constraint(ConstraintDef<?, ?> definition) {
6363
if ( property instanceof JavaBeanField ) {
6464
super.addConstraint(
65-
ConfiguredConstraint.forProperty(
66-
definition, property
65+
ConfiguredConstraint.forFieldProperty(
66+
definition, property.as( JavaBeanField.class )
6767
)
6868
);
6969
}

0 commit comments

Comments
 (0)