public final class ElementHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static Collection<javax.lang.model.element.ExecutableElement> |
findByName(Collection<javax.lang.model.element.ExecutableElement> methods,
javax.lang.model.element.Name methodName)
Returns a collection of methods with the same name.
|
static Collection<javax.lang.model.element.ExecutableElement> |
findByName(Collection<javax.lang.model.element.ExecutableElement> methods,
javax.lang.model.element.Name methodName,
int paramCount)
Returns a collection of methods with the same name.
|
static String |
getPrimaryClassNamePrefix(javax.lang.model.element.TypeElement element)
Returns the primary class simple name prefix for an element
who represents a MessageBundle or MessageLogger interface.
|
static boolean |
hasCause(Collection<? extends javax.lang.model.element.VariableElement> params)
Checks to see if there is a cause parameter.
|
static boolean |
inheritsMessage(Collection<javax.lang.model.element.ExecutableElement> methods,
javax.lang.model.element.ExecutableElement method)
Checks to see if the method has or inherits a
Annotations.message() annotation. |
static boolean |
isAnnotatedWith(javax.lang.model.element.Element element,
Class<? extends Annotation> clazz)
Check if an element is annotated with the given annotation.
|
static boolean |
isAssignableFrom(Class<?> type,
javax.lang.model.element.TypeElement typeElement)
Checks to see if the type is assignable from the type element.
|
static boolean |
isAssignableFrom(Class<?> type,
javax.lang.model.type.TypeMirror typeMirror)
Checks to see if the type is assignable from the type mirror.
|
static boolean |
isAssignableFrom(javax.lang.model.element.TypeElement typeElement,
Class<?> type)
Checks to see if the type element is assignable from the type.
|
static boolean |
isAssignableFrom(javax.lang.model.type.TypeMirror typeMirror,
Class<?> type)
Checks to see id the type mirror is assignable from the type.
|
static boolean |
isOverloaded(Collection<javax.lang.model.element.ExecutableElement> methods,
javax.lang.model.element.ExecutableElement method)
Checks to see if the method is overloaded.
|
static int |
parameterCount(Collection<? extends javax.lang.model.element.VariableElement> params)
Returns the number of parameters excluding the
Annotations.cause() parameter
and any Annotations.param() parameters if found. |
static String |
typeToString(Class<?> type)
Converts a class type to a string recognizable by the
Elements.getTypeElement(CharSequence). |
static String |
typeToString(String qualifiedType)
Converts a qualified type name to a string recognizable by the
Elements.getTypeElement(CharSequence). |
public static boolean isAnnotatedWith(javax.lang.model.element.Element element,
Class<? extends Annotation> clazz)
element - the element to look for the annotation on.clazz - the annotation classNullPointerException - if element parameter is nullpublic static String getPrimaryClassNamePrefix(javax.lang.model.element.TypeElement element)
element - the elementNullPointerException - if element is nullIllegalArgumentException - if element is not an interfacepublic static Collection<javax.lang.model.element.ExecutableElement> findByName(Collection<javax.lang.model.element.ExecutableElement> methods, javax.lang.model.element.Name methodName)
methods - the methods to process.methodName - the method name to find.public static Collection<javax.lang.model.element.ExecutableElement> findByName(Collection<javax.lang.model.element.ExecutableElement> methods, javax.lang.model.element.Name methodName, int paramCount)
methods - the methods to process.methodName - the method name to find.paramCount - the number of parameters the method must have.public static boolean hasCause(Collection<? extends javax.lang.model.element.VariableElement> params)
params - the parameters to check.true if there is a cause, otherwise false.public static int parameterCount(Collection<? extends javax.lang.model.element.VariableElement> params)
Annotations.cause() parameter
and any Annotations.param() parameters if found.params - the parameters to get the count for.public static boolean inheritsMessage(Collection<javax.lang.model.element.ExecutableElement> methods, javax.lang.model.element.ExecutableElement method)
Annotations.message() annotation.methods - the method to search.method - the method to check.true if the method has or inherits a message annotation, otherwise false.public static boolean isOverloaded(Collection<javax.lang.model.element.ExecutableElement> methods, javax.lang.model.element.ExecutableElement method)
Annotations.cause() or Annotations.param()
are not counted.methods - the method to search.method - the method to check.true if the method is overloaded, otherwise false.public static boolean isAssignableFrom(javax.lang.model.element.TypeElement typeElement,
Class<?> type)
typeElement - the type element to check.type - the type to check.true if the type element is assignable from the type,
otherwise false.public static boolean isAssignableFrom(javax.lang.model.type.TypeMirror typeMirror,
Class<?> type)
typeMirror - the type mirror to check.type - the type to check.true if the type mirror is assignable from the type,
otherwise false.public static boolean isAssignableFrom(Class<?> type, javax.lang.model.element.TypeElement typeElement)
type - the type to check.typeElement - the type element to check.true if the type is assignable from the type element,
otherwise false.public static boolean isAssignableFrom(Class<?> type, javax.lang.model.type.TypeMirror typeMirror)
type - the type to check.typeMirror - the type mirror to check.true if the type is assignable from the type mirror,
otherwise false.public static String typeToString(Class<?> type)
Elements.getTypeElement(CharSequence). Essentially replaces any $'s to
. (dots).type - the type to convert.public static String typeToString(String qualifiedType)
Elements.getTypeElement(CharSequence). Essentially replaces any $'s to
. (dots).qualifiedType - the qualified type name.Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.