|
28 | 28 |
|
29 | 29 | import io.avaje.validation.adapter.AnnotationValidationAdapter;
|
30 | 30 | import io.avaje.validation.adapter.ValidationRequest;
|
31 |
| -import jakarta.validation.constraints.AssertTrue; |
32 |
| -import jakarta.validation.constraints.NotBlank; |
33 |
| -import jakarta.validation.constraints.Past; |
34 |
| -import jakarta.validation.constraints.Pattern; |
35 | 31 | import jakarta.validation.constraints.Pattern.Flag;
|
36 |
| -import jakarta.validation.constraints.Size; |
37 | 32 |
|
38 | 33 | final class JakartaTypeAdapters {
|
39 | 34 | private JakartaTypeAdapters() {}
|
40 | 35 |
|
41 | 36 | @SuppressWarnings({"unchecked", "rawtypes"})
|
42 | 37 | static final AnnotationValidationAdapter.Factory FACTORY =
|
43 | 38 | (annotationType, validator, interpolator) -> {
|
44 |
| - if (annotationType == AssertTrue.class) return new AssertTrueAdapter(interpolator); |
45 |
| - if (annotationType == NotBlank.class) return new NotBlankAdapter(interpolator); |
46 |
| - if (annotationType == Past.class) return new PastAdapter(interpolator); |
47 |
| - if (annotationType == Pattern.class) return new PatternAdapter(interpolator); |
48 |
| - if (annotationType == Size.class) return new SizeAdapter(interpolator); |
49 |
| - return null; |
| 39 | + switch (annotationType.getSimpleName()) { |
| 40 | + case "AssertTrue": |
| 41 | + return new AssertTrueAdapter(interpolator); |
| 42 | + case "NotBlank": |
| 43 | + return new NotBlankAdapter(interpolator); |
| 44 | + case "Past": |
| 45 | + return new PastAdapter(interpolator); |
| 46 | + case "Pattern": |
| 47 | + return new PatternAdapter(interpolator); |
| 48 | + case "Size": |
| 49 | + return new SizeAdapter(interpolator); |
| 50 | + default: |
| 51 | + return null; |
| 52 | + } |
50 | 53 | };
|
51 | 54 |
|
52 | 55 | private static final class PatternAdapter implements AnnotationValidationAdapter<CharSequence> {
|
|
0 commit comments