|
24 | 24 | import com.google.auto.common.MoreTypes; |
25 | 25 | import com.google.auto.value.processor.AutoValueOrOneOfProcessor.Property; |
26 | 26 | import com.google.common.collect.ImmutableBiMap; |
| 27 | +import com.google.common.collect.ImmutableList; |
27 | 28 | import com.google.common.collect.ImmutableMap; |
28 | 29 | import com.google.common.collect.ImmutableMultimap; |
29 | 30 | import com.google.common.collect.ImmutableSet; |
|
41 | 42 | import javax.lang.model.element.Modifier; |
42 | 43 | import javax.lang.model.element.TypeElement; |
43 | 44 | import javax.lang.model.element.TypeParameterElement; |
| 45 | +import javax.lang.model.element.VariableElement; |
44 | 46 | import javax.lang.model.type.DeclaredType; |
45 | 47 | import javax.lang.model.type.TypeKind; |
46 | 48 | import javax.lang.model.type.TypeMirror; |
@@ -306,20 +308,16 @@ public PropertySetter(ExecutableElement setter, TypeMirror propertyType) { |
306 | 308 | this.nullableAnnotation = ""; |
307 | 309 | } else { |
308 | 310 | String rawTarget = TypeEncoder.encodeRaw(erasedPropertyType); |
309 | | - Optionalish optional = Optionalish.createIfOptional(propertyType, rawTarget); |
| 311 | + Optionalish optional = Optionalish.createIfOptional(propertyType); |
310 | 312 | String nullableAnnotation = ""; |
311 | | - String of = null; |
| 313 | + String of; |
312 | 314 | if (optional != null) { |
313 | | - for (AnnotationMirror annotationMirror : parameterElement.getAnnotationMirrors()) { |
314 | | - AnnotationOutput annotationOutput = new AnnotationOutput(typeSimplifier); |
315 | | - String annotationName = annotationOutput.sourceFormForAnnotation(annotationMirror); |
316 | | - if (annotationName.equals("@Nullable") || annotationName.endsWith(".Nullable")) { |
317 | | - of = optional.getNullable(); |
318 | | - nullableAnnotation = annotationName + " "; |
319 | | - break; |
320 | | - } |
321 | | - } |
322 | | - if (of == null) { |
| 315 | + ImmutableList<AnnotationMirror> annotationMirrors = ImmutableList.copyOf(parameterElement.getAnnotationMirrors()); |
| 316 | + Optional<String> nullableAnnotationFromParam = AutoValueProcessor.nullableAnnotationIfInList(annotationMirrors); |
| 317 | + if (nullableAnnotationFromParam.isPresent()) { |
| 318 | + of = optional.getNullable(); |
| 319 | + nullableAnnotation = nullableAnnotationFromParam.get() + " "; |
| 320 | + } else { |
323 | 321 | of = "of"; |
324 | 322 | } |
325 | 323 | } else { |
|
0 commit comments