Skip to content

Commit 88ff330

Browse files
committed
HV-1393 Removed Property Kind enum
1 parent 777b201 commit 88ff330

File tree

7 files changed

+9
-48
lines changed

7 files changed

+9
-48
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.hibernate.validator.internal.metadata.raw.ConstrainedProperty;
2424
import org.hibernate.validator.internal.properties.Callable;
2525
import org.hibernate.validator.internal.properties.Property;
26+
import org.hibernate.validator.internal.properties.javabean.JavaBeanField;
2627
import org.hibernate.validator.internal.util.TypeResolutionHelper;
2728

2829
/**
@@ -56,7 +57,7 @@ protected PropertyConstraintMappingContextImpl getThis() {
5657

5758
@Override
5859
public PropertyConstraintMappingContext constraint(ConstraintDef<?, ?> definition) {
59-
if ( property.getKind() == Property.Kind.FIELD ) {
60+
if ( property instanceof JavaBeanField ) {
6061
super.addConstraint(
6162
ConfiguredConstraint.forProperty(
6263
definition, property
@@ -110,7 +111,7 @@ public ContainerElementConstraintMappingContext containerElementType(int index,
110111
}
111112

112113
ConstrainedElement build(ConstraintHelper constraintHelper, TypeResolutionHelper typeResolutionHelper, ValueExtractorManager valueExtractorManager) {
113-
if ( property.getKind() == Property.Kind.FIELD ) {
114+
if ( property instanceof JavaBeanField ) {
114115
return ConstrainedProperty.forField(
115116
ConfigurationSource.API,
116117
property,

engine/src/main/java/org/hibernate/validator/internal/metadata/aggregated/PropertyCascadable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.hibernate.validator.internal.engine.valueextraction.ValueExtractorManager;
1414
import org.hibernate.validator.internal.metadata.facets.Cascadable;
1515
import org.hibernate.validator.internal.properties.Property;
16+
import org.hibernate.validator.internal.properties.javabean.JavaBeanField;
1617

1718
/**
1819
* A {@link Cascadable} backed by a field of a Java bean.
@@ -31,7 +32,7 @@ public class PropertyCascadable implements Cascadable {
3132
this.property = property;
3233
this.cascadableType = property.getType();
3334
this.cascadingMetaData = cascadingMetaData;
34-
this.elementType = property.getKind() == Property.Kind.FIELD ? ElementType.FIELD : ElementType.METHOD;
35+
this.elementType = property instanceof JavaBeanField ? ElementType.FIELD : ElementType.METHOD;
3536
}
3637

3738
@Override

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ enum ConstrainedElementKind {
5050
TYPE, CONSTRUCTOR, METHOD, PARAMETER, PROPERTY
5151
}
5252

53-
enum ConstrainedPropertyKind {
54-
FIELD, GETTER
55-
}
56-
5753
/**
5854
* Returns the kind of this constrained element.
5955
*

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class ConstrainedProperty extends AbstractConstrainedElement {
2222

2323
private final Property property;
2424

25-
private final ConstrainedPropertyKind constrainedPropertyKind;
26-
2725
/**
2826
* Creates a new field meta data object.
2927
*
@@ -37,39 +35,25 @@ private ConstrainedProperty(ConfigurationSource source,
3735
Property property,
3836
Set<MetaConstraint<?>> constraints,
3937
Set<MetaConstraint<?>> typeArgumentConstraints,
40-
CascadingMetaDataBuilder cascadingMetaDataBuilder,
41-
ConstrainedPropertyKind constrainedPropertyKind) {
38+
CascadingMetaDataBuilder cascadingMetaDataBuilder) {
4239

4340
super( source, ConstrainedElementKind.PROPERTY, constraints, typeArgumentConstraints, cascadingMetaDataBuilder );
4441

4542
this.property = property;
46-
this.constrainedPropertyKind = constrainedPropertyKind;
4743
}
4844

4945
public static ConstrainedProperty forField(ConfigurationSource source,
5046
Property property,
5147
Set<MetaConstraint<?>> constraints,
5248
Set<MetaConstraint<?>> typeArgumentConstraints,
5349
CascadingMetaDataBuilder cascadingMetaDataBuilder) {
54-
return new ConstrainedProperty( source, property, constraints, typeArgumentConstraints, cascadingMetaDataBuilder, ConstrainedPropertyKind.FIELD );
55-
}
56-
57-
public static ConstrainedProperty forGetter(ConfigurationSource source,
58-
Property property,
59-
Set<MetaConstraint<?>> constraints,
60-
Set<MetaConstraint<?>> typeArgumentConstraints,
61-
CascadingMetaDataBuilder cascadingMetaDataBuilder) {
62-
return new ConstrainedProperty( source, property, constraints, typeArgumentConstraints, cascadingMetaDataBuilder, ConstrainedPropertyKind.GETTER );
50+
return new ConstrainedProperty( source, property, constraints, typeArgumentConstraints, cascadingMetaDataBuilder );
6351
}
6452

6553
public Property getProperty() {
6654
return property;
6755
}
6856

69-
public ConstrainedPropertyKind getConstrainedPropertyKind() {
70-
return constrainedPropertyKind;
71-
}
72-
7357
@Override
7458
public String toString() {
7559
return "ConstrainedProperty [property=" + property.getName() + "]";
@@ -78,7 +62,6 @@ public String toString() {
7862
@Override public int hashCode() {
7963
int result = super.hashCode();
8064
result = 31 * result + this.property.hashCode();
81-
result = 31 * result + this.constrainedPropertyKind.hashCode();
8265
return result;
8366
}
8467

@@ -96,9 +79,6 @@ public boolean equals(Object o) {
9679

9780
ConstrainedProperty that = (ConstrainedProperty) o;
9881

99-
if ( this.constrainedPropertyKind != that.constrainedPropertyKind ) {
100-
return false;
101-
}
10282
return this.property.equals( that.property );
10383
}
10484
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@
1111
*/
1212
public interface Property extends Constrainable {
1313

14-
enum Kind {
15-
FIELD,
16-
GETTER,
17-
}
18-
1914
Object getValueFrom(Object bean);
2015

21-
Kind getKind();
22-
2316
String getPropertyName();
2417
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ public Object getValueFrom(Object bean) {
5858
return ReflectionHelper.getValue( field, bean );
5959
}
6060

61-
@Override
62-
public Kind getKind() {
63-
return Kind.FIELD;
64-
}
65-
6661
@Override
6762
public String getPropertyName() {
6863
return getName();
@@ -121,7 +116,7 @@ private static Field getAccessible(Field original) {
121116

122117
/**
123118
* Runs the given privileged action, using a privileged block if required.
124-
* <p>
119+
*
125120
* <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary
126121
* privileged actions within HV's protection domain.
127122
*/

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ public Object getValueFrom(Object bean) {
3737
return ReflectionHelper.getValue( (Method) executable, bean );
3838
}
3939

40-
@Override
41-
public Kind getKind() {
42-
return Kind.GETTER;
43-
}
44-
4540
@Override
4641
public String getPropertyName() {
4742
return name;
@@ -120,7 +115,7 @@ private static Method getAccessible(Method original) {
120115

121116
/**
122117
* Runs the given privileged action, using a privileged block if required.
123-
* <p>
118+
*
124119
* <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary
125120
* privileged actions within HV's protection domain.
126121
*/

0 commit comments

Comments
 (0)