@@ -17,15 +17,15 @@ private NumberAdapters() {}
17
17
public static final ValidationContext .AnnotationFactory FACTORY =
18
18
(annotationType , context , attributes ) ->
19
19
switch (annotationType .getSimpleName ()) {
20
- case "Digits" -> new DigitsAdapter (context .message ( "Digits" , attributes ), attributes );
21
- case "Positive" -> new PositiveAdapter (context .message ( "Positive" , attributes ));
20
+ case "Digits" -> new DigitsAdapter (context .message2 ( attributes ), attributes );
21
+ case "Positive" -> new PositiveAdapter (context .message2 ( attributes ));
22
22
case "PositiveOrZero" -> new PositiveAdapter (
23
- context .message ( "PositiveOrZero" , attributes ), true );
24
- case "Negative" -> new NegativeAdapter (context .message ( "Negative" , attributes ));
23
+ context .message2 ( attributes ), true );
24
+ case "Negative" -> new NegativeAdapter (context .message2 ( attributes ));
25
25
case "NegativeOrZero" -> new NegativeAdapter (
26
- context .message ( "NegativeOrZero" , attributes ), true );
27
- case "Max" -> new MaxAdapter (context .message ( "Max" , attributes ), attributes );
28
- case "Min" -> new MinAdapter (context .message ( "Min" , attributes ), attributes );
26
+ context .message2 ( attributes ), true );
27
+ case "Max" -> new MaxAdapter (context .message2 ( attributes ), attributes );
28
+ case "Min" -> new MinAdapter (context .message2 ( attributes ), attributes );
29
29
case "DecimalMax" -> new DecimalMaxAdapter (
30
30
context .message2 (attributes ), attributes );
31
31
case "DecimalMin" -> new DecimalMinAdapter (
@@ -98,10 +98,10 @@ public boolean validate(Number number, ValidationRequest req, String propertyNam
98
98
99
99
private static final class MaxAdapter implements ValidationAdapter <Number > {
100
100
101
- private final String message ;
101
+ private final ValidationContext . Message message ;
102
102
private final long value ;
103
103
104
- public MaxAdapter (String message , Map <String , Object > attributes ) {
104
+ public MaxAdapter (ValidationContext . Message message , Map <String , Object > attributes ) {
105
105
this .message = message ;
106
106
this .value = (long ) attributes .get ("value" );
107
107
}
@@ -114,7 +114,7 @@ public boolean validate(Number number, ValidationRequest req, String propertyNam
114
114
return true ;
115
115
}
116
116
117
- if (NumberComparatorHelper .compare (number , value , GREATER_THAN ) < 0 ) {
117
+ if (NumberComparatorHelper .compare (number , value , GREATER_THAN ) > 0 ) {
118
118
req .addViolation (message , propertyName );
119
119
return false ;
120
120
}
@@ -125,10 +125,10 @@ public boolean validate(Number number, ValidationRequest req, String propertyNam
125
125
126
126
private static final class MinAdapter implements ValidationAdapter <Number > {
127
127
128
- private final String message ;
128
+ private final ValidationContext . Message message ;
129
129
private final long value ;
130
130
131
- public MinAdapter (String message , Map <String , Object > attributes ) {
131
+ public MinAdapter (ValidationContext . Message message , Map <String , Object > attributes ) {
132
132
this .message = message ;
133
133
this .value = (long ) attributes .get ("value" );
134
134
}
@@ -141,7 +141,7 @@ public boolean validate(Number number, ValidationRequest req, String propertyNam
141
141
return true ;
142
142
}
143
143
144
- if (NumberComparatorHelper .compare (number , value , LESS_THAN ) > 0 ) {
144
+ if (NumberComparatorHelper .compare (number , value , LESS_THAN ) < 0 ) {
145
145
req .addViolation (message , propertyName );
146
146
return false ;
147
147
}
@@ -152,11 +152,11 @@ public boolean validate(Number number, ValidationRequest req, String propertyNam
152
152
153
153
private static final class DigitsAdapter implements ValidationAdapter <Object > {
154
154
155
- private final String message ;
155
+ private final ValidationContext . Message message ;
156
156
private final int integer ;
157
157
private final int fraction ;
158
158
159
- public DigitsAdapter (String message , Map <String , Object > attributes ) {
159
+ public DigitsAdapter (ValidationContext . Message message , Map <String , Object > attributes ) {
160
160
this .message = message ;
161
161
this .integer = (int ) attributes .get ("integer" );
162
162
this .fraction = (int ) attributes .get ("fraction" );
@@ -191,15 +191,15 @@ public boolean validate(Object value, ValidationRequest req, String propertyName
191
191
192
192
private static final class PositiveAdapter implements ValidationAdapter <Object > {
193
193
194
- private final String message ;
194
+ private final ValidationContext . Message message ;
195
195
private final boolean inclusive ;
196
196
197
- public PositiveAdapter (String message ) {
197
+ public PositiveAdapter (ValidationContext . Message message ) {
198
198
this .message = message ;
199
199
this .inclusive = false ;
200
200
}
201
201
202
- public PositiveAdapter (String message , boolean inclusive ) {
202
+ public PositiveAdapter (ValidationContext . Message message , boolean inclusive ) {
203
203
this .message = message ;
204
204
this .inclusive = inclusive ;
205
205
}
@@ -225,15 +225,15 @@ public boolean validate(Object value, ValidationRequest req, String propertyName
225
225
226
226
private static final class NegativeAdapter implements ValidationAdapter <Object > {
227
227
228
- private final String message ;
228
+ private final ValidationContext . Message message ;
229
229
private final boolean inclusive ;
230
230
231
- public NegativeAdapter (String message , boolean inclusive ) {
231
+ public NegativeAdapter (ValidationContext . Message message , boolean inclusive ) {
232
232
this .message = message ;
233
233
this .inclusive = inclusive ;
234
234
}
235
235
236
- public NegativeAdapter (String message ) {
236
+ public NegativeAdapter (ValidationContext . Message message ) {
237
237
this .message = message ;
238
238
this .inclusive = false ;
239
239
}
0 commit comments