Package org.eclipse.yasson.internal
Class AnnotationIntrospector
java.lang.Object
org.eclipse.yasson.internal.AnnotationIntrospector
Introspects configuration on classes and their properties by reading annotations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final List<Class<? extends Annotation>>Annotations to report exception when used in combination withJsonbTransient. -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationIntrospector(JsonbContext jsonbContext) Creates annotation introspecting component passingJsonbContextinside. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckTransientIncompatible(JsonbAnnotatedElement<?> target) Finds annotations incompatible withJsonbTransientannotation.collectAnnotations(Class<?> clazz) Collect annotations of given class, its interfaces and the package.collectInterfaces(Class<?> cls) Get class interfaces recursively.getAdapterBinding(JsonbAnnotatedElement<Class<?>> clsElement) Checks forJsonbAdapteron a type.getAdapterBinding(Property property) Checks forJsonbAdapteron a property.ReturnsJsonbDateFormatterinstance ifJsonbDateFormatannotation is present.ReturnsJsonbNumberFormatterinstance ifJsonbNumberFormatannotation is present.getCreator(Class<?> clazz) Searches for JsonbCreator annotation on constructors and static methods.getDeserializerBinding(JsonbAnnotatedElement<Class<?>> clsElement) Checks forJsonbDeserializeron a type.getDeserializerBinding(Property property) Checks forJsonbDeserializeron a property.Class<?>getImplementationClass(Property property) Returns class ifImplementationClassannotation is present.getJsonbDateFormat(JsonbAnnotatedElement<Class<?>> clazzElement) Search forJsonbDateFormatannotation on java class and constructJsonbDateFormatter.getJsonbDateFormatCategorized(Property property) SearchJsonbDateFormaton property, if not found looks at annotations declared on property type class.getJsonbNumberFormat(JsonbAnnotatedElement<Class<?>> clazzElement) Search forJsonbNumberFormatannotation on java class.getJsonbPropertyJsonReadName(Property property) Gets a name of property for JSON unmarshalling.getJsonbPropertyJsonWriteName(Property property) Gets a name of property for JSON marshalling.getJsonbTransientCategorized(Property property) Checks if property is annotated transient.getJsonNumberFormatter(Property property) SearchJsonbNumberFormaton property, if not found looks at annotations declared on property type class.String[]getPropertyOrder(JsonbAnnotatedElement<Class<?>> clazzElement) Checks forJsonbPropertyOrderannotation.javax.json.bind.config.PropertyVisibilityStrategygetPropertyVisibilityStrategy(Class<?> clazz) Get a @JsonbVisibility annotation from a class or its package.getSerializerBinding(JsonbAnnotatedElement<Class<?>> clsElement) Checks forJsonbSerializeron a type.getSerializerBinding(Property property) Checks forJsonbSerializeron a property.introspectCustomization(JsonbAnnotatedElement<Class<?>> clsElement) Processes customizations.booleanisClassNillable(JsonbAnnotatedElement<Class<?>> clazzElement) Checks for JsonbNillable annotation on a class, its superclasses and interfaces.isPropertyNillable(Property property) Checks if property is nillable.
-
Field Details
-
TRANSIENT_INCOMPATIBLE
Annotations to report exception when used in combination withJsonbTransient.
-
-
Constructor Details
-
AnnotationIntrospector
Creates annotation introspecting component passingJsonbContextinside.- Parameters:
jsonbContext- mandatory
-
-
Method Details
-
getJsonbPropertyJsonWriteName
Gets a name of property for JSON marshalling. Can be different writeName for same property.- Parameters:
property- property representation - field, getter, setter (not null)- Returns:
- read name
-
getJsonbPropertyJsonReadName
Gets a name of property for JSON unmarshalling. Can be different from writeName for same property.- Parameters:
property- property representation - field, getter, setter (not null)- Returns:
- write name
-
getCreator
Searches for JsonbCreator annotation on constructors and static methods.- Parameters:
clazz- class to search- Returns:
- JsonbCreator metadata object
-
getAdapterBinding
Checks forJsonbAdapteron a property.- Parameters:
property- property not null- Returns:
- components info
-
getAdapterBinding
Checks forJsonbAdapteron a type.- Parameters:
clsElement- type not null- Returns:
- components info
-
getDeserializerBinding
Checks forJsonbDeserializeron a property.- Parameters:
property- property not null- Returns:
- components info
-
getDeserializerBinding
Checks forJsonbDeserializeron a type.- Parameters:
clsElement- type not null- Returns:
- components info
-
getSerializerBinding
Checks forJsonbSerializeron a property.- Parameters:
property- property not null- Returns:
- components info
-
getSerializerBinding
Checks forJsonbSerializeron a type.- Parameters:
clsElement- type not null- Returns:
- components info
-
isPropertyNillable
Checks if property is nillable. Looks forJsonbPropertynillable attribute only. JsonbNillable is checked only for ClassModels.- Parameters:
property- property to search in, not null- Returns:
- True if property should be serialized when null.
-
isClassNillable
Checks for JsonbNillable annotation on a class, its superclasses and interfaces.- Parameters:
clazzElement- class to search JsonbNillable in.- Returns:
- true if found
-
getPropertyOrder
Checks forJsonbPropertyOrderannotation.- Parameters:
clazzElement- class to search on- Returns:
- ordered properties names or null if not found
-
getJsonbTransientCategorized
Checks if property is annotated transient. If JsonbTransient annotation is present on field getter or setter, and other annotation is present on either of it, JsonbException is thrown with message describing collision.- Parameters:
property- The property to inspect if there is anyJsonbTransientannotation defined for it- Returns:
- Set of
AnnotationTargets specifying in which scope theJsonbTransientis applied
-
getJsonbDateFormatCategorized
SearchJsonbDateFormaton property, if not found looks at annotations declared on property type class.- Parameters:
property- Property to search on.- Returns:
- Map of
JsonbDateFormatterinstances categorized by their scopes (class, property, getter or setter). If there is no date formatter specified for given property, an empty map would be returned
-
getJsonbDateFormat
Search forJsonbDateFormatannotation on java class and constructJsonbDateFormatter. If not found looks at annotations declared on property type class.- Parameters:
clazzElement- class to search not null- Returns:
- formatter to use
-
getJsonbNumberFormat
Search forJsonbNumberFormatannotation on java class.- Parameters:
clazzElement- class to search not null- Returns:
- formatter to use
-
getJsonNumberFormatter
SearchJsonbNumberFormaton property, if not found looks at annotations declared on property type class.- Parameters:
property- Property to search on.- Returns:
- Map of
JsonbNumberFormatterinstances categorized by their scopes (class, property, getter or setter). If there is no number formatter specified for given property, an empty map would be returned
-
getConstructorNumberFormatter
ReturnsJsonbNumberFormatterinstance ifJsonbNumberFormatannotation is present.- Parameters:
param- annotated method parameter- Returns:
- formatter instance if
JsonbNumberFormatis present otherwise null
-
getConstructorDateFormatter
ReturnsJsonbDateFormatterinstance ifJsonbDateFormatannotation is present.- Parameters:
param- annotated method parameter- Returns:
- formatter instance if
JsonbDateFormatis present otherwise null
-
getPropertyVisibilityStrategy
public javax.json.bind.config.PropertyVisibilityStrategy getPropertyVisibilityStrategy(Class<?> clazz) Get a @JsonbVisibility annotation from a class or its package.- Parameters:
clazz- Class to lookup annotation- Returns:
- Instantiated PropertyVisibilityStrategy if annotation is present
-
checkTransientIncompatible
Finds annotations incompatible withJsonbTransientannotation.- Parameters:
target- target to check
-
collectInterfaces
Get class interfaces recursively.- Parameters:
cls- Class to process.- Returns:
- A list of all class interfaces.
-
introspectCustomization
Processes customizations.- Parameters:
clsElement- Element to process.- Returns:
- Populated
ClassCustomizationinstance.
-
getImplementationClass
Returns class ifImplementationClassannotation is present.- Parameters:
property- annotated property- Returns:
- Class if
ImplementationClassis present otherwise null
-
collectAnnotations
Collect annotations of given class, its interfaces and the package.- Parameters:
clazz- Class to process.- Returns:
- Element with class and annotations.
-