|
47 | 47 |
|
48 | 48 | class MethodParameterPojoExtractor {
|
49 | 49 |
|
50 |
| - private MethodParameterPojoExtractor() { } |
| 50 | + private MethodParameterPojoExtractor() { |
| 51 | + } |
51 | 52 |
|
52 | 53 | private static final Nullable NULLABLE_ANNOTATION = getNullable();
|
53 | 54 |
|
@@ -90,9 +91,10 @@ private static Stream<MethodParameter> fromGetterOfField(Class<?> paramClass, Fi
|
90 | 91 |
|
91 | 92 | private static Stream<MethodParameter> fromSimpleClass(Class<?> paramClass, Field field, String fieldNamePrefix) {
|
92 | 93 | Annotation[] fieldAnnotations = field.getDeclaredAnnotations();
|
93 |
| - if (isOptional(field)) |
94 |
| - fieldAnnotations = ArrayUtils.add(fieldAnnotations, NULLABLE_ANNOTATION); |
95 | 94 | try {
|
| 95 | + Nullable nullableField = NULLABLE_ANNOTATION; |
| 96 | + if (isOptional(field)) |
| 97 | + fieldAnnotations = ArrayUtils.add(fieldAnnotations, nullableField); |
96 | 98 | Annotation[] finalFieldAnnotations = fieldAnnotations;
|
97 | 99 | return Stream.of(Introspector.getBeanInfo(paramClass).getPropertyDescriptors())
|
98 | 100 | .filter(d -> d.getName().equals(field.getName()))
|
@@ -142,11 +144,17 @@ static void removeSimpleTypes(Class<?>... classes) {
|
142 | 144 | SIMPLE_TYPES.removeAll(Arrays.asList(classes));
|
143 | 145 | }
|
144 | 146 |
|
| 147 | + private class NullableFieldClass { |
| 148 | + @Nullable |
| 149 | + private String nullableField; |
| 150 | + } |
| 151 | + |
145 | 152 | private static Nullable getNullable() {
|
146 |
| - return new Nullable() { |
147 |
| - public Class<? extends Annotation> annotationType() { |
148 |
| - return Nullable.class; |
149 |
| - } |
150 |
| - }; |
| 153 | + try { |
| 154 | + return NullableFieldClass.class.getDeclaredField("nullableField").getAnnotation(Nullable.class); |
| 155 | + } |
| 156 | + catch (NoSuchFieldException e) { |
| 157 | + return null; |
| 158 | + } |
151 | 159 | }
|
152 | 160 | }
|
0 commit comments