Package ball.annotation.processing
Class JavaxLangModelUtilities
- java.lang.Object
-
- ball.annotation.processing.JavaxLangModelUtilities
-
- Direct Known Subclasses:
AbstractProcessor
public abstract class JavaxLangModelUtilities extends Object
Utility methods forProcessor
andTaglet
implementations.- Author:
- Allen D. Ball
-
-
Field Summary
Fields Modifier and Type Field Description protected Elements
elements
protected JavaFileManager
fm
JavacTask
JavaFileManager
instance.protected Types
types
-
Constructor Summary
Constructors Constructor Description JavaxLangModelUtilities()
-
Method Summary
-
-
-
Field Detail
-
fm
protected JavaFileManager fm
JavacTask
JavaFileManager
instance.
-
-
Constructor Detail
-
JavaxLangModelUtilities
public JavaxLangModelUtilities()
-
-
Method Detail
-
getClassLoader
protected ClassLoader getClassLoader()
Method to get theClassLoader
for loading dependencies.- Returns:
- The
ClassLoader
.
-
isGenerated
protected boolean isGenerated(Element element)
-
asClass
protected Class<?> asClass(TypeElement element)
Method to get theClass
corresponding to aTypeElement
.- Parameters:
element
- TheTypeElement
.- Returns:
- The
Class
for theTypeElement
.
-
asPackageInfoClass
protected Class<?> asPackageInfoClass(PackageElement element)
- Parameters:
element
- ThePackageElement
.- Returns:
- The
Class
for thePackageElement
package-info.class
.
-
asTypeElement
protected TypeElement asTypeElement(Class<?> type)
Method to get aTypeElement
for aClass
.- Parameters:
type
- TheClass
.- Returns:
- The
TypeElement
for theClass
.
-
asExecutableElement
protected ExecutableElement asExecutableElement(Constructor<?> constructor)
Method to get aExecutableElement
for aConstructor
.- Parameters:
constructor
- TheConstructor
.- Returns:
- The
ExecutableElement
for theConstructor
.
-
asExecutableElement
protected ExecutableElement asExecutableElement(Method method)
Method to get aExecutableElement
for aMethod
.- Parameters:
method
- TheMethod
.- Returns:
- The
ExecutableElement
for theMethod
.
-
asVariableElement
protected VariableElement asVariableElement(Field field)
Method to get aVariableElement
for aField
.- Parameters:
field
- TheField
.- Returns:
- The
VariableElement
for theField
.
-
asTypeMirror
protected TypeMirror asTypeMirror(Class<?> type)
Method to get aTypeMirror
for aClass
.- Parameters:
type
- TheClass
.- Returns:
- The
TypeMirror
for theClass
.
-
asTypeMirrorList
protected List<TypeMirror> asTypeMirrorList(Class<?>... types)
- Parameters:
types
- The array ofClass
es.- Returns:
- The
List
ofTypeMirror
s.
-
getEnclosingTypeElement
protected TypeElement getEnclosingTypeElement(Element element)
Method to get the enclosingTypeElement
for anElement
.- Parameters:
element
- TheElement
.- Returns:
- The enclosing
TypeElement
.
-
getTypeElementFor
protected TypeElement getTypeElementFor(Element context, String name)
Method to get theTypeElement
for a contextElement
.- Parameters:
context
- The contextElement
.name
- The name of theElement
(Class
).- Returns:
- The context's
TypeElement
.
-
getConstructor
protected ExecutableElement getConstructor(TypeElement type, List<TypeMirror> parameters)
- Parameters:
type
- TheTypeElement
.parameters
- The constructor parameter types.- Returns:
- The
ExecutableElement
for the constructor.
-
getMethod
protected ExecutableElement getMethod(TypeElement type, Method method)
Method to get anExecutableElement
for aMethod
prototype.- Parameters:
type
- TheTypeElement
.method
- The prototypeMethod
.- Returns:
- The
ExecutableElement
for the method.
-
overrides
protected ExecutableElement overrides(ExecutableElement overrider)
- Parameters:
overrider
- TheExecutableElement
.- Returns:
- The overridden
ExecutableElement
if any;null
otherwise. - See Also:
Elements.overrides(ExecutableElement,ExecutableElement,TypeElement)
-
overrides
protected boolean overrides(ExecutableElement overrider, ExecutableElement overridden)
- Parameters:
overrider
- The (possibly) overridingExecutableElement
.overridden
- The overriddenExecutableElement
.- Returns:
true
ifoverrider
overridesoverridden
;false
otherwise.- See Also:
Elements.overrides(ExecutableElement,ExecutableElement,TypeElement)
-
implementationOf
protected ExecutableElement implementationOf(ExecutableElement overridden, TypeElement type)
Method to return theExecutableElement
(Method
) the argumentExecutableElement
is overriden by (if any).- Parameters:
overridden
- TheExecutableElement
.type
- TheTypeElement
.- Returns:
- The overriding
ExecutableElement
if any;null
otherwise. - See Also:
overrides(ExecutableElement)
-
specifiedBy
protected ExecutableElement specifiedBy(ExecutableElement method)
Method to return theExecutableElement
(Method
) the argumentExecutableElement
is specified by (if any).- Parameters:
method
- TheExecutableElement
.- Returns:
- The specification
ExecutableElement
if any;null
otherwise. - See Also:
overrides(ExecutableElement)
-
signature
protected String signature(Executable executable)
Method to generate the application signature of anExecutable
.- Parameters:
executable
- TheExecutable
.- Returns:
- The signature
String
.
-
signature
protected String signature(ExecutableElement element)
Method to generate the application signature of anExecutableElement
.- Parameters:
element
- TheExecutableElement
.- Returns:
- The signature
String
.
-
getAnnotationMirror
protected AnnotationMirror getAnnotationMirror(Element element, Class<? extends Annotation> type)
Method to get anElement
'sAnnotationMirror
.- Parameters:
element
- The annotatedElement
.type
- TheAnnotation
type (Class
).- Returns:
- The
AnnotationMirror
if theElement
is annotated with the argument annotation;null
otherwise. - See Also:
Element.getAnnotationMirrors()
-
getAnnotationMirror
protected AnnotationMirror getAnnotationMirror(Element element, TypeElement type)
Method to get anElement
'sAnnotationMirror
.- Parameters:
element
- The annotatedElement
.type
- TheAnnotation
type (TypeElement
).- Returns:
- The
AnnotationMirror
if theElement
is annotated with the argument annotation;null
otherwise. - See Also:
Element.getAnnotationMirrors()
-
getAnnotationValue
protected AnnotationValue getAnnotationValue(AnnotationMirror annotation, String name)
Method to get anAnnotationMirror
element'sAnnotationValue
.- Parameters:
annotation
- TheAnnotationMirror
.name
- The simple name of the element.- Returns:
- The
AnnotationValue
if it is defined;null
otherwise. - See Also:
Elements.getElementValuesWithDefaults(AnnotationMirror)
-
isEmptyArray
protected boolean isEmptyArray(AnnotationValue value)
Method to determine if anAnnotationValue
is "empty":null
or an empty array.- Parameters:
value
- TheAnnotationValue
.- Returns:
true
if empty; {code false} otherwise.
-
getPropertyName
protected String getPropertyName(ExecutableElement element)
Method to get bean property name from anExecutableElement
.- Parameters:
element
- TheExecutableElement
.- Returns:
- the name
String
if theExecutableElement
is a getter or setter method;null
otherwise.
-
isGetterMethod
protected boolean isGetterMethod(ExecutableElement element)
Method to determine if anExecutableElement
is a bean getter.- Parameters:
element
- TheExecutableElement
.- Returns:
true
if theElement
has a non-private getter method;false
otherwise.
-
getPropertyNames
protected Set<String> getPropertyNames(TypeElement type)
Method to get theSet
of bean property names for the specifiedTypeElement
.- Parameters:
type
- TheTypeElement
to analyze.- Returns:
- The
Set
of bean property names.
-
hasSameSignatureAs
protected Predicate<Element> hasSameSignatureAs(List<TypeMirror> parameters)
-
hasSameSignatureAs
protected Predicate<Element> hasSameSignatureAs(Executable executable)
-
hasSameSignatureAs
protected Predicate<Element> hasSameSignatureAs(CharSequence name, Class<?>[] parameters)
-
isAssignableTo
protected Predicate<Element> isAssignableTo(Class<?> type)
-
isAssignableTo
protected Predicate<Element> isAssignableTo(TypeMirror type)
-
isAssignableTo
protected Predicate<Element> isAssignableTo(Class<?> type, Function<? super Element,TypeMirror> extractor)
-
isAssignableTo
protected Predicate<Element> isAssignableTo(TypeMirror type, Function<? super Element,TypeMirror> extractor)
-
named
protected Predicate<Element> named(CharSequence name)
-
withParameters
protected Predicate<Element> withParameters(Class<?>[] parameters)
-
withParameters
protected Predicate<Element> withParameters(List<TypeMirror> parameters)
-
withModifiers
protected Predicate<Element> withModifiers(Modifier... modifiers)
-
withModifiers
protected Predicate<Element> withModifiers(Set<Modifier> modifiers)
-
withoutModifiers
protected Predicate<Element> withoutModifiers(Modifier... modifiers)
-
withoutModifiers
protected Predicate<Element> withoutModifiers(Set<Modifier> modifiers)
-
without
protected <E> Predicate<Element> without(Set<E> set, Function<Element,Collection<E>> extractor)
-
getClassPathClassLoader
protected ClassLoader getClassPathClassLoader(JavaFileManager fm, ClassLoader parent)
- Parameters:
fm
- TheJavaFileManager
.parent
- The parentClassLoader
.- Returns:
- The
ClassLoader
.
-
getClassPathClassLoader
protected ClassLoader getClassPathClassLoader(JavaFileManager fm)
- Parameters:
fm
- TheJavaFileManager
.- Returns:
- The
ClassLoader
.
-
toModifiers
public static int toModifiers(Set<Modifier> set)
- Parameters:
set
- TheModifier
s.- Returns:
- The flags.
-
-