|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.openjpa.persistence.meta.SourceAnnotationHandler
public class SourceAnnotationHandler
Extracts persistent metadata information by analyzing available annotation in *.java source files. Requires JDK6 Annotation Processing environment available.
Nested Class Summary | |
---|---|
(package private) static class |
SourceAnnotationHandler.AccessFilter
Selects elements which is annotated with @Access annotation and that annotation has the given AccessType value. |
(package private) static class |
SourceAnnotationHandler.AnnotatedFilter
Selects all annotated element. |
(package private) static class |
SourceAnnotationHandler.GetterFilter
Selects getter method. |
(package private) static class |
SourceAnnotationHandler.KindFilter
Selects elements of given kind. |
(package private) static class |
SourceAnnotationHandler.SetterFilter
Selects setter method. |
(package private) static class |
SourceAnnotationHandler.TransientFilter
Selects all non-transient element. |
Field Summary | |
---|---|
protected SourceAnnotationHandler.AnnotatedFilter |
annotatedFilter
|
protected SourceAnnotationHandler.AccessFilter |
fieldAccessFilter
|
protected SourceAnnotationHandler.KindFilter |
fieldFilter
|
protected SourceAnnotationHandler.GetterFilter |
getterFilter
|
protected static List<Class<? extends Annotation>> |
mappingAnnos
|
protected SourceAnnotationHandler.KindFilter |
methodFilter
|
protected SourceAnnotationHandler.TransientFilter |
nonTransientFilter
|
protected SourceAnnotationHandler.AccessFilter |
propertyAccessFilter
Set of Inclusion Filters based on member type, access type or transient annotations. |
protected SourceAnnotationHandler.SetterFilter |
setterFilter
|
Constructor Summary | |
---|---|
SourceAnnotationHandler(javax.annotation.processing.ProcessingEnvironment processingEnv,
CompileTimeLogger logger)
Construct with JDK6 annotation processing environment. |
Method Summary | ||
---|---|---|
javax.lang.model.type.TypeMirror |
box(javax.lang.model.type.TypeMirror t)
|
|
int |
determineMemberAccess(javax.lang.model.element.Element m)
Determine the access type of the given member. |
|
int |
determineTypeAccess(javax.lang.model.element.TypeElement type)
Determine the access type of the given type. |
|
static boolean |
equalsByValue(Enum<?> e,
Object v)
Affirms if the given enum equals the given value. |
|
String |
extractFieldName(javax.lang.model.element.ExecutableElement method)
|
|
(package private)
|
filter(Collection<T> coll,
org.apache.openjpa.persistence.meta.SourceAnnotationHandler.InclusiveFilter... filters)
Filter the given collection with the conjunction of filters. |
|
static Object |
getAnnotationValue(javax.lang.model.element.Element decl,
Class<? extends Annotation> anno)
Gets the value of the given annotation, if present, in the given declaration. |
|
static Object |
getAnnotationValue(javax.lang.model.element.Element e,
Class<? extends Annotation> anno,
String attr)
Gets the value of the given attribute of the given annotation, if present, in the given declaration. |
|
(package private) javax.lang.model.type.TypeMirror |
getDeclaredType(javax.lang.model.element.Element e)
Gets the declared type of the given member. |
|
(package private) String |
getDeclaredTypeName(javax.lang.model.type.TypeMirror mirror)
|
|
(package private) String |
getDeclaredTypeName(javax.lang.model.type.TypeMirror mirror,
boolean box)
Get the element name of the class the given mirror represents. |
|
(package private) AccessType |
getExplicitAccessType(javax.lang.model.element.TypeElement type)
Get access type of the given class, if specified explicitly. |
|
(package private) String |
getPersistentMemberName(javax.lang.model.element.Element e)
|
|
Set<javax.lang.model.element.Element> |
getPersistentMembers(javax.lang.model.element.TypeElement type)
Gets the list of persistent fields and/or methods for the given type. |
|
javax.lang.model.element.TypeElement |
getPersistentSupertype(javax.lang.model.element.TypeElement cls)
|
|
(package private) javax.lang.model.type.TypeMirror |
getTargetEntityType(javax.lang.model.element.Element e)
|
|
(package private) javax.lang.model.type.TypeMirror |
getTypeParameter(javax.lang.model.element.Element e,
javax.lang.model.type.TypeMirror mirror,
int index,
boolean checkTarget)
Gets the parameter type argument at the given index of the given type. |
|
static boolean |
isAnnotated(javax.lang.model.element.Element e)
Affirms if the given element is annotated with any javax.persistence.* or org.apache.openjpa.*
annotation. |
|
(package private) boolean |
isAnnotatedAsEntity(javax.lang.model.element.Element e)
Affirms if the given declaration has the given annotation. |
|
static boolean |
isAnnotatedWith(javax.lang.model.element.Element e,
Class<? extends Annotation> anno)
Affirms if the given declaration has the given annotation. |
|
static boolean |
isAnnotatedWith(javax.lang.model.element.Element e,
Set<String> annos)
Affirms if the given element is annotated with any of the given annotations. |
|
static boolean |
isBoolean(javax.lang.model.type.TypeMirror type)
Affirms if the given mirror represents a primitive or non-primitive boolean. |
|
static boolean |
isBooleanGetter(javax.lang.model.element.ExecutableElement method)
Affirms if the given method matches the following signature public boolean isXyz()
public Boolean isXyz() |
|
static boolean |
isGetter(javax.lang.model.element.ExecutableElement method)
|
|
static boolean |
isMethod(javax.lang.model.element.Element e)
Affirms if the given element represents a method. |
|
boolean |
isMixedAccess(javax.lang.model.element.TypeElement t)
Affirms if the members of given type are using both field and property based access. |
|
static boolean |
isNormalGetter(javax.lang.model.element.ExecutableElement method)
Affirms if the given method matches the following signature public T getXXX()
where T is any non-void type. |
|
static boolean |
isRootObject(javax.lang.model.type.TypeMirror type)
Affirms if the given mirror represents root java.lang.Object. |
|
static boolean |
isSetter(javax.lang.model.element.ExecutableElement method)
Affirms if the given method matches the following signature public void setXXX(T t) |
|
static boolean |
isVoid(javax.lang.model.type.TypeMirror type)
Affirms if the given mirror represents a void. |
|
(package private) Set<javax.lang.model.element.Element> |
merge(Set<? extends javax.lang.model.element.Element> a,
Set<? extends javax.lang.model.element.Element> b)
|
|
static boolean |
startsWith(String full,
String head)
Affirms if the given full string starts with the given head. |
|
(package private) String |
toDetails(javax.lang.model.element.Element e)
|
|
static String |
toString(Collection<? extends javax.lang.model.element.Element> elements)
|
|
List<Exception> |
validateAccess(javax.lang.model.element.TypeElement t)
Gets the violations, if any. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SourceAnnotationHandler.AccessFilter propertyAccessFilter
protected SourceAnnotationHandler.AccessFilter fieldAccessFilter
protected SourceAnnotationHandler.KindFilter fieldFilter
protected SourceAnnotationHandler.KindFilter methodFilter
protected SourceAnnotationHandler.TransientFilter nonTransientFilter
protected SourceAnnotationHandler.AnnotatedFilter annotatedFilter
protected SourceAnnotationHandler.GetterFilter getterFilter
protected SourceAnnotationHandler.SetterFilter setterFilter
protected static List<Class<? extends Annotation>> mappingAnnos
Constructor Detail |
---|
public SourceAnnotationHandler(javax.annotation.processing.ProcessingEnvironment processingEnv, CompileTimeLogger logger)
Method Detail |
---|
public int determineTypeAccess(javax.lang.model.element.TypeElement type)
MetadataProcessor
determineTypeAccess
in interface MetadataProcessor<javax.lang.model.element.TypeElement,javax.lang.model.element.Element>
public int determineMemberAccess(javax.lang.model.element.Element m)
MetadataProcessor
determineMemberAccess
in interface MetadataProcessor<javax.lang.model.element.TypeElement,javax.lang.model.element.Element>
public List<Exception> validateAccess(javax.lang.model.element.TypeElement t)
MetadataProcessor
validateAccess
in interface MetadataProcessor<javax.lang.model.element.TypeElement,javax.lang.model.element.Element>
public boolean isMixedAccess(javax.lang.model.element.TypeElement t)
MetadataProcessor
isMixedAccess
in interface MetadataProcessor<javax.lang.model.element.TypeElement,javax.lang.model.element.Element>
public Set<javax.lang.model.element.Element> getPersistentMembers(javax.lang.model.element.TypeElement type)
getPersistentMembers
in interface MetadataProcessor<javax.lang.model.element.TypeElement,javax.lang.model.element.Element>
Set<javax.lang.model.element.Element> merge(Set<? extends javax.lang.model.element.Element> a, Set<? extends javax.lang.model.element.Element> b)
<T extends javax.lang.model.element.Element> Set<T> filter(Collection<T> coll, org.apache.openjpa.persistence.meta.SourceAnnotationHandler.InclusiveFilter... filters)
AccessType getExplicitAccessType(javax.lang.model.element.TypeElement type)
type
-
public static Object getAnnotationValue(javax.lang.model.element.Element decl, Class<? extends Annotation> anno)
public static Object getAnnotationValue(javax.lang.model.element.Element e, Class<? extends Annotation> anno, String attr)
public static String toString(Collection<? extends javax.lang.model.element.Element> elements)
String toDetails(javax.lang.model.element.Element e)
String getPersistentMemberName(javax.lang.model.element.Element e)
public String extractFieldName(javax.lang.model.element.ExecutableElement method)
public static boolean isAnnotated(javax.lang.model.element.Element e)
javax.persistence.*
or org.apache.openjpa.*
annotation.
boolean isAnnotatedAsEntity(javax.lang.model.element.Element e)
public static boolean isAnnotatedWith(javax.lang.model.element.Element e, Class<? extends Annotation> anno)
public static boolean isAnnotatedWith(javax.lang.model.element.Element e, Set<String> annos)
annos
- null checks for any annotation that starts with
'javax.persistence.' or 'openjpa.*'.javax.lang.model.type.TypeMirror getTargetEntityType(javax.lang.model.element.Element e)
String getDeclaredTypeName(javax.lang.model.type.TypeMirror mirror)
String getDeclaredTypeName(javax.lang.model.type.TypeMirror mirror, boolean box)
java.util.Set<java.lang.String>
this method will
return java.util.Set
.
javax.lang.model.type.TypeMirror getDeclaredType(javax.lang.model.element.Element e)
e
- a field or method.
if
- given member is neither a field nor a method.public javax.lang.model.type.TypeMirror box(javax.lang.model.type.TypeMirror t)
javax.lang.model.type.TypeMirror getTypeParameter(javax.lang.model.element.Element e, javax.lang.model.type.TypeMirror mirror, int index, boolean checkTarget)
public javax.lang.model.element.TypeElement getPersistentSupertype(javax.lang.model.element.TypeElement cls)
getPersistentSupertype
in interface MetadataProcessor<javax.lang.model.element.TypeElement,javax.lang.model.element.Element>
public static boolean isBoolean(javax.lang.model.type.TypeMirror type)
public static boolean isVoid(javax.lang.model.type.TypeMirror type)
public static boolean isMethod(javax.lang.model.element.Element e)
public static boolean isNormalGetter(javax.lang.model.element.ExecutableElement method)
public T getXXX()
where T is any non-void type.
public static boolean isBooleanGetter(javax.lang.model.element.ExecutableElement method)
public boolean isXyz()
public Boolean isXyz()
public static boolean isGetter(javax.lang.model.element.ExecutableElement method)
public static boolean isSetter(javax.lang.model.element.ExecutableElement method)
public void setXXX(T t)
public static boolean isRootObject(javax.lang.model.type.TypeMirror type)
public static boolean startsWith(String full, String head)
public static boolean equalsByValue(Enum<?> e, Object v)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |