public class ElementAnnotationApplier extends Object
In a way, this class is a hack: the Type representation for the Elements should contain all annotations that we want. However, due to javac bugs http://mail.openjdk.java.net/pipermail/type-annotations-dev/2013-December/001449.html decoding the type annotations from the Element is necessary.
Even once these bugs are fixed, this class might be useful: in TypesIntoElements it is easy to add additional annotations to the element and have them stored in the bytecode by the compiler. It would be more work (and might not work in the end) to instead modify the Type directly. The interaction between TypeFromElement and TypesIntoElements allows us to write the defaulted annotations into the Element and have them read later by other parts.
|Constructor and Description|
|Modifier and Type||Method and Description|
Annotate the list of supertypes using the annotations on the TypeElement representing a class or interface.
Add all of the relevant annotations stored in Element to type.
Helper method to get the lambda tree for ParamApplier.
public static void apply(AnnotatedTypeMirror type, Element element, AnnotatedTypeFactory typeFactory)
Note: Element annotations come from two sources.
TypesIntoElements). Subsequent, calls to apply will encounter these annotations on the provided element.
type- the type to which we wish to apply the element's annotations
element- an element that possibly contains annotations
typeFactory- the typeFactory used to create the given type
public static void annotateSupers(List<AnnotatedTypeMirror.AnnotatedDeclaredType> supertypes, TypeElement subtypeElement)
supertypes- types representing supertype declarations of TypeElement
subtypeElement- an element representing the declaration of the class which is a subtype of supertypes
public static Pair<VariableTree,LambdaExpressionTree> getParamAndLambdaTree(VariableElement varEle, AnnotatedTypeFactory typeFactory)
varEle- the element that may represent a lambda's parameter