Class BeanMutatorAccessorResolver.AnnotationPropertyResolver
- java.lang.Object
-
- com.oracle.coherence.io.json.genson.reflect.BeanMutatorAccessorResolver.AnnotationPropertyResolver
-
- All Implemented Interfaces:
BeanMutatorAccessorResolver
- Direct Known Subclasses:
BeanMutatorAccessorResolver.GensonAnnotationPropertyResolver
- Enclosing interface:
- BeanMutatorAccessorResolver
public static class BeanMutatorAccessorResolver.AnnotationPropertyResolver extends Object implements BeanMutatorAccessorResolver
A basicAnnotationscanningBeanMutatorAccessorResolverassuming the use of three primaryAnnotations:-
propertyAnnotation: an annotation, such asJsonProperty, denoting a property to serialize/deserialize. -
exclusionAnnotation: an annotation, such asJsonIgnoredenoting an exclusion of a property from serialization/deserialization. -
creatorAnnotation: an annotation, such asJsonCreatordenoting a constructor or factory method to use when deserializing an entity.
- Since:
- 1.5.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.oracle.coherence.io.json.genson.reflect.BeanMutatorAccessorResolver
BeanMutatorAccessorResolver.AnnotationPropertyResolver, BeanMutatorAccessorResolver.CompositeResolver, BeanMutatorAccessorResolver.GensonAnnotationPropertyResolver, BeanMutatorAccessorResolver.PropertyBaseResolver, BeanMutatorAccessorResolver.StandardMutaAccessorResolver
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<? extends Annotation>creatorAnnotationAnAnnotationthat functions similarly toJsonCreator.protected Class<? extends Annotation>exclusionAnnotationAnAnnotationthat functions similarly toJsonIgnore.protected Class<? extends Annotation>propertyAnnotationAnAnnotationthat functions similarly toJsonProperty.
-
Constructor Summary
Constructors Constructor Description AnnotationPropertyResolver(Class<? extends Annotation> propertyAnnotation, Class<? extends Annotation> exclusionAnnotation, Class<? extends Annotation> creatorAnnotation)Create a new resolver for the specified annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <A extends Annotation>
Afind(Class<A> annotation, Class<?> onClass)Scan for the argumentAnnotationon the argumentClass.protected <A extends Annotation>
Afind(Class<A> annotation, Class<?> inClass, String methodName, Class<?>... parameterTypes)Scan for the argumentAnnotationon a method matching the argument method names and parameters.protected <A extends Annotation>
Afind(Class<A> annotation, AccessibleObject onObject, Class<?> onClass)Scan for the argumentAnnotationon the argumentAccessibleObject.protected StringgetGetterName(Method method)Return the property name based on argumentMethod.protected StringgetSetterName(Method method)Return the property name based on argumentMethod.protected booleanignore(AccessibleObject property, Class<?> ofType, boolean forSerialization)Scans for the presence of theexclusionAnnotation/protected booleaninclude(AccessibleObject property, Class<?> ofType, boolean forSerialization)Scans for the presence of thepropertyAnnotation.TrileanisAccessor(Field field, Class<?> fromClass)Determines if the configuredpropertyAnnotationis present on the providedField.TrileanisAccessor(Method method, Class<?> fromClass)Determines if the configuredpropertyAnnotationis present on the providedField.TrileanisCreator(Constructor<?> constructor, Class<?> fromClass)Determines if the configuredcreatorAnnotationis present on the providedConstructor.TrileanisCreator(Method method, Class<?> fromClass)Determines if the configuredcreatorAnnotationis present on the providedMethod.booleanisCreatorAnnotated(Constructor<?> constructor)booleanisCreatorAnnotated(Method method)TrileanisMutator(Field field, Class<?> fromClass)Determines if the configuredpropertyAnnotationis present on the providedField.TrileanisMutator(Method method, Class<?> fromClass)Determines if the configuredpropertyAnnotationis present on the providedField.
-
-
-
Field Detail
-
propertyAnnotation
protected Class<? extends Annotation> propertyAnnotation
AnAnnotationthat functions similarly toJsonProperty.
-
exclusionAnnotation
protected Class<? extends Annotation> exclusionAnnotation
AnAnnotationthat functions similarly toJsonIgnore.
-
creatorAnnotation
protected Class<? extends Annotation> creatorAnnotation
-
-
Constructor Detail
-
AnnotationPropertyResolver
public AnnotationPropertyResolver(Class<? extends Annotation> propertyAnnotation, Class<? extends Annotation> exclusionAnnotation, Class<? extends Annotation> creatorAnnotation)
Create a new resolver for the specified annotations. The notion of property, exclusion, and creator will be carried forward in the documentation of the class.- Parameters:
propertyAnnotation-exclusionAnnotation-creatorAnnotation-
-
-
Method Detail
-
isCreator
public Trilean isCreator(Constructor<?> constructor, Class<?> fromClass)
Determines if the configuredcreatorAnnotationis present on the providedConstructor.- Specified by:
isCreatorin interfaceBeanMutatorAccessorResolver- Parameters:
constructor- theConstructorto scanfromClass- theClasstheConstructoris associated with- Returns:
Trilean.TRUEif thecreatorAnnotationis found, otherwiseTrilean.UNKNOWN
-
isCreator
public Trilean isCreator(Method method, Class<?> fromClass)
Determines if the configuredcreatorAnnotationis present on the providedMethod.- Specified by:
isCreatorin interfaceBeanMutatorAccessorResolver- Parameters:
method- theMethodto scanfromClass- theClasstheMethodis associated with- Returns:
Trilean.TRUEif thecreatorAnnotationis found, otherwiseTrilean.UNKNOWN- Throws:
JsonBindingException- if the annotatedMethodis notpublicandstatic
-
isCreatorAnnotated
public boolean isCreatorAnnotated(Constructor<?> constructor)
- Specified by:
isCreatorAnnotatedin interfaceBeanMutatorAccessorResolver
-
isCreatorAnnotated
public boolean isCreatorAnnotated(Method method)
- Specified by:
isCreatorAnnotatedin interfaceBeanMutatorAccessorResolver
-
isAccessor
public Trilean isAccessor(Field field, Class<?> fromClass)
Determines if the configuredpropertyAnnotationis present on the providedField. Invoked during serialization.- Specified by:
isAccessorin interfaceBeanMutatorAccessorResolver- Parameters:
field- theFieldto scanfromClass- theClasstheFieldis associated with- Returns:
Trilean.FALSEif theFieldis annotated with theexclusionAnnotation,Trilean.TRUEif thepropertyAnnotationis found, otherwise returnsTrilean.UNKNOWN
-
isAccessor
public Trilean isAccessor(Method method, Class<?> fromClass)
Determines if the configuredpropertyAnnotationis present on the providedField. Invoked during serialization.- Specified by:
isAccessorin interfaceBeanMutatorAccessorResolver- Parameters:
method- theMethodto scanfromClass- theClasstheFieldis associated with- Returns:
Trilean.FALSEif theMethodis annotated with theexclusionAnnotation,Trilean.TRUEif thepropertyAnnotationis found, otherwise returnsTrilean.UNKNOWN
-
isMutator
public Trilean isMutator(Field field, Class<?> fromClass)
Determines if the configuredpropertyAnnotationis present on the providedField. Invoked during deserialization.- Specified by:
isMutatorin interfaceBeanMutatorAccessorResolver- Parameters:
field- theFieldto scanfromClass- theClasstheFieldis associated with- Returns:
Trilean.FALSEif theFieldis annotated with theexclusionAnnotation,Trilean.TRUEif thepropertyAnnotationis found, otherwise returnsTrilean.UNKNOWN
-
isMutator
public Trilean isMutator(Method method, Class<?> fromClass)
Determines if the configuredpropertyAnnotationis present on the providedField. Invoked during serialization.- Specified by:
isMutatorin interfaceBeanMutatorAccessorResolver- Parameters:
method- theMethodto scanfromClass- theClasstheFieldis associated with- Returns:
Trilean.FALSEif theMethodis annotated with theexclusionAnnotation,Trilean.TRUEif thepropertyAnnotationis found, otherwise returnsTrilean.UNKNOWN
-
getGetterName
protected String getGetterName(Method method)
Return the property name based on argumentMethod. This assumes agetterusing standard Java Beans naming conventions.- Parameters:
method- theMethodto extract the name from- Returns:
- the property name or
nullif the method isn't agetter.
-
getSetterName
protected String getSetterName(Method method)
Return the property name based on argumentMethod. This assumes asetterusing standard Java Beans naming conventions.- Parameters:
method- theMethodto extract the name from- Returns:
- the property name or
nullif the method isn't asetter.
-
ignore
protected boolean ignore(AccessibleObject property, Class<?> ofType, boolean forSerialization)
Scans for the presence of theexclusionAnnotation/- Parameters:
property- the property to scanofType- the associatedClassforSerialization- flag indicating if this exclusion check is for a serialization or deserialization operation- Returns:
trueif theAnnotationis found, otherwisefalse
-
include
protected boolean include(AccessibleObject property, Class<?> ofType, boolean forSerialization)
Scans for the presence of thepropertyAnnotation.- Parameters:
property- the property to scanofType- the associatedClassforSerialization- flag indicating if this exclusion check is for a serialization or deserialization operation- Returns:
trueif theAnnotationis found, otherwisefalse
-
find
protected <A extends Annotation> A find(Class<A> annotation, AccessibleObject onObject, Class<?> onClass)
Scan for the argumentAnnotationon the argumentAccessibleObject.- Parameters:
annotation- theAnnotationto scan foronObject- the entity that may be annotated with the specifiedAnnotationonClass- theClassassociated with theAccessibleObject- Returns:
- the
Annotationif found, otherwise returnsnull
-
find
protected <A extends Annotation> A find(Class<A> annotation, Class<?> onClass)
Scan for the argumentAnnotationon the argumentClass.- Parameters:
annotation- theAnnotationto scan foronClass- theClassto scan- Returns:
- the
Annotationif found, otherwise returnsnull
-
find
protected <A extends Annotation> A find(Class<A> annotation, Class<?> inClass, String methodName, Class<?>... parameterTypes)
Scan for the argumentAnnotationon a method matching the argument method names and parameters.- Parameters:
annotation- the Annotation to scan forinClass- theClassto search for a matching methodmethodName- the method's nameparameterTypes- the method's argument types- Returns:
- the
Annotationif found, otherwise returnsnull
-
-