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
FieldsModifier and TypeFieldDescriptionprotected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AnnotatedFilterprotected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AccessFilterprotected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.KindFilterprotected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.GetterFilterprotected static List<Class<? extends Annotation>>protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.KindFilterprotected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.TransientFilterprotected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.AccessFilterSet of Inclusion Filters based on member type, access type or transient annotations.protected org.apache.openjpa.persistence.meta.SourceAnnotationHandler.SetterFilter -
Constructor Summary
ConstructorsConstructorDescriptionSourceAnnotationHandler(ProcessingEnvironment processingEnv, CompileTimeLogger logger) Construct with JDK6 annotation processing environment. -
Method Summary
Modifier and TypeMethodDescriptionbox(TypeMirror t) intDetermine the access type of the given member.intDetermine the access type of the given type.static booleanequalsByValue(Enum<?> e, Object v) Affirms if the given enum equals the given value.extractFieldName(ExecutableElement method) static ObjectgetAnnotationValue(Element decl, Class<? extends Annotation> anno) Gets the value of the given annotation, if present, in the given declaration.static ObjectgetAnnotationValue(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 booleanAffirms if the given element is annotated with anyjakarta.persistencestatic booleanisAnnotatedWith(Element e, Class<? extends Annotation> anno) Affirms if the given declaration has the given annotation.static booleanisAnnotatedWith(Element e, Set<String> annos) Affirms if the given element is annotated with any of the given annotations.static booleanisBoolean(TypeMirror type) Affirms if the given mirror represents a primitive or non-primitive boolean.static booleanisBooleanGetter(ExecutableElement method) Affirms if the given method matches the following signaturepublic boolean isXyz()public Boolean isXyz()static booleanisGetter(ExecutableElement method) static booleanAffirms if the given element represents a method.booleanAffirms if the members of given type are using both field and property based access.static booleanisNormalGetter(ExecutableElement method) Affirms if the given method matches the following signaturepublic T getXXX()where T is any non-void type.static booleanisRootObject(TypeMirror type) Affirms if the given mirror represents root java.lang.Object.static booleanisSetter(ExecutableElement method) Affirms if the given method matches the following signaturepublic void setXXX(T t)static booleanisVoid(TypeMirror type) Affirms if the given mirror represents a void.static booleanstartsWith(String full, String head) Affirms if the given full string starts with the given head.static StringtoString(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:MetadataProcessorDetermine the access type of the given type.- Specified by:
determineTypeAccessin interfaceMetadataProcessor<TypeElement,Element> - Returns:
- an integer denoting the type of access. The integer value corresponds to ClassMetaData.getAccessType().
-
determineMemberAccess
Description copied from interface:MetadataProcessorDetermine the access type of the given member.- Specified by:
determineMemberAccessin interfaceMetadataProcessor<TypeElement,Element> - Returns:
- an integer denoting the type of access. The integer value corresponds to FieldMetaData.getAccessType().
-
validateAccess
Description copied from interface:MetadataProcessorGets the violations, if any.- Specified by:
validateAccessin interfaceMetadataProcessor<TypeElement,Element> - Returns:
- null or empty list if no exceptions.
-
isMixedAccess
Description copied from interface:MetadataProcessorAffirms if the members of given type are using both field and property based access.- Specified by:
isMixedAccessin 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:
getPersistentMembersin 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:
getPersistentSupertypein 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.
-