Class SourceAnnotationHandler
java.lang.Object
org.apache.openjpa.persistence.meta.SourceAnnotationHandler
- All Implemented Interfaces:
MetadataProcessor<TypeElement,
Element>
public class SourceAnnotationHandler
extends Object
implements MetadataProcessor<TypeElement,Element>
Extracts persistent metadata information by analyzing available annotation
in *.java source files. Requires JDK6 Annotation Processing environment
available.
- Since:
- 2.0.0
- Author:
- Pinaki Poddar
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AnnotatedFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AccessFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.KindFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.GetterFilter
protected static List<Class<? extends Annotation>>
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.KindFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.TransientFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AccessFilter
Set of Inclusion Filters based on member type, access type or transient annotations.protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.SetterFilter
-
Constructor Summary
ConstructorDescriptionSourceAnnotationHandler
(ProcessingEnvironment processingEnv, CompileTimeLogger logger) Construct with JDK6 annotation processing environment. -
Method Summary
Modifier and TypeMethodDescriptionbox
(TypeMirror t) int
Determine the access type of the given member.int
Determine the access type of the given type.static boolean
equalsByValue
(Enum<?> e, Object v) Affirms if the given enum equals the given value.extractFieldName
(ExecutableElement method) static Object
getAnnotationValue
(Element decl, Class<? extends Annotation> anno) Gets the value of the given annotation, if present, in the given declaration.static Object
getAnnotationValue
(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.Gets the list of persistent fields and/or methods for the given type.static boolean
Affirms if the given element is annotated with anyjakarta.persistence
static boolean
isAnnotatedWith
(Element e, Class<? extends Annotation> anno) Affirms if the given declaration has the given annotation.static boolean
isAnnotatedWith
(Element e, Set<String> annos) Affirms if the given element is annotated with any of the given annotations.static boolean
isBoolean
(TypeMirror type) Affirms if the given mirror represents a primitive or non-primitive boolean.static boolean
isBooleanGetter
(ExecutableElement method) Affirms if the given method matches the following signaturepublic boolean isXyz()
public Boolean isXyz()
static boolean
isGetter
(ExecutableElement method) static boolean
Affirms if the given element represents a method.boolean
Affirms if the members of given type are using both field and property based access.static boolean
isNormalGetter
(ExecutableElement method) Affirms if the given method matches the following signaturepublic T getXXX()
where T is any non-void type.static boolean
isRootObject
(TypeMirror type) Affirms if the given mirror represents root java.lang.Object.static boolean
isSetter
(ExecutableElement method) Affirms if the given method matches the following signaturepublic void setXXX(T t)
static boolean
isVoid
(TypeMirror type) Affirms if the given mirror represents a void.static boolean
startsWith
(String full, String head) Affirms if the given full string starts with the given head.static String
toString
(Collection<? extends Element> elements) Gets the violations, if any.
-
Field Details
-
propertyAccessFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AccessFilter propertyAccessFilterSet of Inclusion Filters based on member type, access type or transient annotations. Used to determine the subset of available field/method that are persistent. -
fieldAccessFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AccessFilter fieldAccessFilter -
fieldFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.KindFilter fieldFilter -
methodFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.KindFilter methodFilter -
nonTransientFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.TransientFilter nonTransientFilter -
annotatedFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AnnotatedFilter annotatedFilter -
getterFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.GetterFilter getterFilter -
setterFilter
protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.SetterFilter setterFilter -
mappingAnnos
-
-
Constructor Details
-
SourceAnnotationHandler
Construct with JDK6 annotation processing environment.
-
-
Method Details
-
determineTypeAccess
Description copied from interface:MetadataProcessor
Determine the access type of the given type.- Specified by:
determineTypeAccess
in interfaceMetadataProcessor<TypeElement,
Element> - Returns:
- an integer denoting the type of access. The integer value corresponds to ClassMetaData.getAccessType().
-
determineMemberAccess
Description copied from interface:MetadataProcessor
Determine the access type of the given member.- Specified by:
determineMemberAccess
in interfaceMetadataProcessor<TypeElement,
Element> - Returns:
- an integer denoting the type of access. The integer value corresponds to FieldMetaData.getAccessType().
-
validateAccess
Description copied from interface:MetadataProcessor
Gets the violations, if any.- Specified by:
validateAccess
in interfaceMetadataProcessor<TypeElement,
Element> - Returns:
- null or empty list if no exceptions.
-
isMixedAccess
Description copied from interface:MetadataProcessor
Affirms if the members of given type are using both field and property based access.- Specified by:
isMixedAccess
in interfaceMetadataProcessor<TypeElement,
Element>
-
getPersistentMembers
Gets the list of persistent fields and/or methods for the given type. Scans relevant @AccessType annotation and field/method as per JPA specification to determine the candidate set of field/methods.- Specified by:
getPersistentMembers
in interfaceMetadataProcessor<TypeElement,
Element>
-
getAnnotationValue
Gets the value of the given annotation, if present, in the given declaration. Otherwise, null. -
getAnnotationValue
Gets the value of the given attribute of the given annotation, if present, in the given declaration. Otherwise, null. -
toString
-
extractFieldName
-
isAnnotated
Affirms if the given element is annotated with anyjakarta.persistence.*
ororg.apache.openjpa.*
annotation. -
isAnnotatedWith
Affirms if the given declaration has the given annotation. -
isAnnotatedWith
Affirms if the given element is annotated with any of the given annotations.- Parameters:
annos
- null checks for any annotation that starts with 'jakarta.persistence.' or 'openjpa.*'.
-
box
-
getPersistentSupertype
- Specified by:
getPersistentSupertype
in interfaceMetadataProcessor<TypeElement,
Element>
-
isBoolean
Affirms if the given mirror represents a primitive or non-primitive boolean. -
isVoid
Affirms if the given mirror represents a void. -
isMethod
Affirms if the given element represents a method. -
isNormalGetter
Affirms if the given method matches the following signaturepublic T getXXX()
where T is any non-void type. -
isBooleanGetter
Affirms if the given method matches the following signaturepublic boolean isXyz()
public Boolean isXyz()
-
isGetter
-
isSetter
Affirms if the given method matches the following signaturepublic void setXXX(T t)
-
isRootObject
Affirms if the given mirror represents root java.lang.Object. -
startsWith
Affirms if the given full string starts with the given head. -
equalsByValue
Affirms if the given enum equals the given value.
-