public final class ElementUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static com.google.common.collect.ImmutableSet<java.lang.String> |
buildAnnotations(javax.lang.model.element.ExecutableElement element)
Builds a
ImmutableSet containing the names of all annotations of the given
element. |
static java.lang.Object |
getAnnotationValue(javax.lang.model.element.Element element,
java.lang.Class<? extends java.lang.annotation.Annotation> clazz,
java.lang.String key)
If the given
element is annotated with an Annotation of class clazz
it's value for key will be returned. |
static com.google.common.base.Optional<javax.lang.model.element.ExecutableElement> |
getMatchingAbstractMethod(java.util.Set<javax.lang.model.element.ExecutableElement> methods,
com.squareup.javapoet.TypeName returns,
com.squareup.javapoet.TypeName... takes)
Returns a method of
cls that is abstract, has returns as return type and the
number and types of parameters match takes. |
static com.google.common.base.Optional<javax.lang.model.element.ExecutableElement> |
getMatchingStaticMethod(javax.lang.model.element.TypeElement cls,
com.squareup.javapoet.TypeName returns,
com.squareup.javapoet.TypeName... takes)
Returns a method of
cls that is static, has returns as return type and the
number and types of parameters match takes. |
static boolean |
hasAnnotationWithName(javax.lang.model.element.Element element,
java.lang.String simpleName)
Returns true if the given
element is annotated with an annotation named
simpleName. |
static boolean |
typeExists(javax.lang.model.util.Elements elements,
com.squareup.javapoet.ClassName className)
Returns true if given
className is on the current classpath. |
public static com.google.common.base.Optional<javax.lang.model.element.ExecutableElement> getMatchingStaticMethod(javax.lang.model.element.TypeElement cls,
com.squareup.javapoet.TypeName returns,
com.squareup.javapoet.TypeName... takes)
cls that is static, has returns as return type and the
number and types of parameters match takes. Returns null if such a method doesn't
exist.public static com.google.common.base.Optional<javax.lang.model.element.ExecutableElement> getMatchingAbstractMethod(java.util.Set<javax.lang.model.element.ExecutableElement> methods,
com.squareup.javapoet.TypeName returns,
com.squareup.javapoet.TypeName... takes)
cls that is abstract, has returns as return type and the
number and types of parameters match takes. Returns null if such a method doesn't
exist.public static boolean typeExists(javax.lang.model.util.Elements elements,
com.squareup.javapoet.ClassName className)
className is on the current classpath.public static boolean hasAnnotationWithName(javax.lang.model.element.Element element,
java.lang.String simpleName)
element is annotated with an annotation named
simpleName.public static com.google.common.collect.ImmutableSet<java.lang.String> buildAnnotations(javax.lang.model.element.ExecutableElement element)
ImmutableSet containing the names of all annotations of the given
element.public static java.lang.Object getAnnotationValue(javax.lang.model.element.Element element,
java.lang.Class<? extends java.lang.annotation.Annotation> clazz,
java.lang.String key)
element is annotated with an Annotation of class clazz
it's value for key will be returned. Otherwise it will return null.java.lang.IllegalArgumentException - if no element is defined with the given key.