| 1 | package com.ancientprogramming.fixedformat4j.format.impl; | |
| 2 | ||
| 3 | import java.lang.reflect.AnnotatedElement; | |
| 4 | import java.lang.reflect.Method; | |
| 5 | ||
| 6 | /** | |
| 7 | * Pairs a getter {@link Method} (used for invocation and type resolution) with an | |
| 8 | * {@link AnnotatedElement} (used for supplementary annotation lookup). When the | |
| 9 | * {@code @Field} annotation is on the getter, both references point to the same object. | |
| 10 | * When it is on a Java field, they differ. | |
| 11 | * | |
| 12 | * @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> | |
| 13 | * @since 1.6.0 | |
| 14 | */ | |
| 15 | class AnnotationTarget { | |
| 16 | ||
| 17 | final Method getter; | |
| 18 | final AnnotatedElement annotationSource; | |
| 19 | ||
| 20 | private AnnotationTarget(Method getter, AnnotatedElement annotationSource) { | |
| 21 | this.getter = getter; | |
| 22 | this.annotationSource = annotationSource; | |
| 23 | } | |
| 24 | ||
| 25 | /** Annotation is on the getter — getter serves as both invoker and annotation source. */ | |
| 26 | static AnnotationTarget ofMethod(Method method) { | |
| 27 |
1
1. ofMethod : replaced return value with null for com/ancientprogramming/fixedformat4j/format/impl/AnnotationTarget::ofMethod → KILLED |
return new AnnotationTarget(method, method); |
| 28 | } | |
| 29 | ||
| 30 | /** Annotation is on a Java field — getter is derived, field is the annotation source. */ | |
| 31 | static AnnotationTarget ofField(Method getter, java.lang.reflect.Field field) { | |
| 32 |
1
1. ofField : replaced return value with null for com/ancientprogramming/fixedformat4j/format/impl/AnnotationTarget::ofField → KILLED |
return new AnnotationTarget(getter, field); |
| 33 | } | |
| 34 | } | |
Mutations | ||
| 27 |
1.1 |
|
| 32 |
1.1 |