16
16
*/
17
17
package org .hibernate .validator .internal .engine ;
18
18
19
+ import java .io .Serializable ;
19
20
import java .lang .annotation .ElementType ;
20
21
import javax .validation .ConstraintViolation ;
21
22
import javax .validation .Path ;
25
26
* @author Emmanuel Bernard
26
27
* @author Hardy Ferentschik
27
28
*/
28
- public class ConstraintViolationImpl <T > implements ConstraintViolation <T >, java . io . Serializable {
29
+ public class ConstraintViolationImpl <T > implements ConstraintViolation <T >, Serializable {
29
30
30
31
private static final long serialVersionUID = -4970067626703103139L ;
31
32
@@ -53,34 +54,42 @@ public ConstraintViolationImpl(String messageTemplate, String interpolatedMessag
53
54
this .elementType = elementType ;
54
55
}
55
56
57
+ @ Override
56
58
public final String getMessage () {
57
59
return interpolatedMessage ;
58
60
}
59
61
62
+ @ Override
60
63
public final String getMessageTemplate () {
61
64
return messageTemplate ;
62
65
}
63
66
67
+ @ Override
64
68
public final T getRootBean () {
65
69
return rootBean ;
66
70
}
67
71
72
+ @ Override
68
73
public final Class <T > getRootBeanClass () {
69
74
return rootBeanClass ;
70
75
}
71
76
77
+ @ Override
72
78
public final Object getLeafBean () {
73
79
return leafBeanInstance ;
74
80
}
75
81
82
+ @ Override
76
83
public final Object getInvalidValue () {
77
84
return value ;
78
85
}
79
86
87
+ @ Override
80
88
public final Path getPropertyPath () {
81
89
return propertyPath ;
82
90
}
83
91
92
+ @ Override
84
93
public final ConstraintDescriptor <?> getConstraintDescriptor () {
85
94
return this .constraintDescriptor ;
86
95
}
@@ -91,11 +100,11 @@ public boolean equals(Object o) {
91
100
if ( this == o ) {
92
101
return true ;
93
102
}
94
- if ( !( o instanceof ConstraintViolationImpl ) ) {
103
+ if ( o == null || getClass () != o . getClass ( ) ) {
95
104
return false ;
96
105
}
97
106
98
- ConstraintViolationImpl <?> that = ( ConstraintViolationImpl <?> ) o ;
107
+ ConstraintViolationImpl <?> that = (ConstraintViolationImpl <?>) o ;
99
108
100
109
if ( interpolatedMessage != null ? !interpolatedMessage .equals ( that .interpolatedMessage ) : that .interpolatedMessage != null ) {
101
110
return false ;
@@ -109,9 +118,18 @@ public boolean equals(Object o) {
109
118
if ( leafBeanInstance != null ? !leafBeanInstance .equals ( that .leafBeanInstance ) : that .leafBeanInstance != null ) {
110
119
return false ;
111
120
}
121
+ if ( constraintDescriptor != null ? !constraintDescriptor .equals ( that .constraintDescriptor ) : that .constraintDescriptor != null ) {
122
+ return false ;
123
+ }
112
124
if ( elementType != null ? !elementType .equals ( that .elementType ) : that .elementType != null ) {
113
125
return false ;
114
126
}
127
+ if ( messageTemplate != null ? !messageTemplate .equals ( that .messageTemplate ) : that .messageTemplate != null ) {
128
+ return false ;
129
+ }
130
+ if ( rootBeanClass != null ? !rootBeanClass .equals ( that .rootBeanClass ) : that .rootBeanClass != null ) {
131
+ return false ;
132
+ }
115
133
if ( value != null ? !value .equals ( that .value ) : that .value != null ) {
116
134
return false ;
117
135
}
@@ -126,6 +144,9 @@ public int hashCode() {
126
144
result = 31 * result + ( rootBean != null ? rootBean .hashCode () : 0 );
127
145
result = 31 * result + ( leafBeanInstance != null ? leafBeanInstance .hashCode () : 0 );
128
146
result = 31 * result + ( value != null ? value .hashCode () : 0 );
147
+ result = 31 * result + ( constraintDescriptor != null ? constraintDescriptor .hashCode () : 0 );
148
+ result = 31 * result + ( messageTemplate != null ? messageTemplate .hashCode () : 0 );
149
+ result = 31 * result + ( rootBeanClass != null ? rootBeanClass .hashCode () : 0 );
129
150
result = 31 * result + ( elementType != null ? elementType .hashCode () : 0 );
130
151
return result ;
131
152
}
0 commit comments