java.lang.Object
org.eclipse.yasson.internal.AnnotationIntrospector
Introspects configuration on classes and their properties by reading annotations.
-
Constructor Summary
ConstructorDescriptionAnnotationIntrospector
(JsonbContext jsonbContext) Creates annotation introspecting component passingJsonbContext
inside. -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkTransientIncompatible
(JsonbAnnotatedElement<?> target) Finds annotations incompatible withJsonbTransient
annotation.collectAnnotations
(Class<?> clazz) Collect annotations of given class, its interfaces and the package.collectInterfaces
(Class<?> cls) Get class interfaces recursively.getAdapterBinding
(Parameter parameter) Checks forJsonbAdapter
on aParameter
.getAdapterBinding
(JsonbAnnotatedElement<Class<?>> clsElement) Checks forJsonbAdapter
on a type.getAdapterBinding
(Property property) Checks forJsonbAdapter
on a property.ReturnsJsonbDateFormatter
instance ifJsonbDateFormat
annotation is present.ReturnsJsonbNumberFormatter
instance ifJsonbNumberFormat
annotation is present.getCreator
(Class<?> clazz, jakarta.json.bind.config.PropertyNamingStrategy propertyNamingStrategy) Searches for JsonbCreator annotation on constructors and static methods.getDeserializerBinding
(Parameter parameter) Checks forJsonbDeserializer
on aParameter
.getDeserializerBinding
(JsonbAnnotatedElement<Class<?>> clsElement) Checks forJsonbDeserializer
on a type.getDeserializerBinding
(Property property) Checks forJsonbDeserializer
on a property.Class<?>
getImplementationClass
(Property property) Returns class ifImplementationClass
annotation is present.getJsonbDateFormat
(JsonbAnnotatedElement<Class<?>> clazzElement) Search forJsonbDateFormat
annotation on java class and constructJsonbDateFormatter
.getJsonbDateFormatCategorized
(Property property) SearchJsonbDateFormat
on property, if not found looks at annotations declared on property type class.getJsonbNumberFormat
(JsonbAnnotatedElement<Class<?>> clazzElement) Search forJsonbNumberFormat
annotation 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) SearchJsonbNumberFormat
on property, if not found looks at annotations declared on property type class.String[]
getPropertyOrder
(JsonbAnnotatedElement<Class<?>> clazzElement) Checks forJsonbPropertyOrder
annotation.jakarta.json.bind.config.PropertyVisibilityStrategy
getPropertyVisibilityStrategy
(Class<?> clazz) Get a @JsonbVisibility annotation from a class or its package.getSerializerBinding
(JsonbAnnotatedElement<Class<?>> clsElement) Checks forJsonbSerializer
on a type.getSerializerBinding
(Property property) Checks forJsonbSerializer
on a property.introspectCustomization
(JsonbAnnotatedElement<Class<?>> clsElement, ClassCustomization parentCustomization, jakarta.json.bind.config.PropertyNamingStrategy propertyNamingStrategy) Processes customizations.boolean
isClassNillable
(JsonbAnnotatedElement<Class<?>> clazzElement) Checks for JsonbNillable annotation on a class, its superclasses and interfaces.isPropertyNillable
(Property property) Checks if property is nillable.boolean
requiredParameters
(Executable executable, JsonbAnnotatedElement<Parameter> annotated)
-
Constructor Details
-
AnnotationIntrospector
Creates annotation introspecting component passingJsonbContext
inside.- 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
public JsonbCreator getCreator(Class<?> clazz, jakarta.json.bind.config.PropertyNamingStrategy propertyNamingStrategy) Searches for JsonbCreator annotation on constructors and static methods.- Parameters:
clazz
- class to searchpropertyNamingStrategy
- The naming strategy to use for the $JsonbConstructor
annotation, if set and noJsonbProperty
annotations are present.- Returns:
- JsonbCreator metadata object
-
getAdapterBinding
Checks forJsonbAdapter
on a property.- Parameters:
property
- property not null- Returns:
- components info
-
getAdapterBinding
Checks forJsonbAdapter
on a type.- Parameters:
clsElement
- type not null- Returns:
- components info
-
getDeserializerBinding
Checks forJsonbDeserializer
on a property.- Parameters:
property
- property not null- Returns:
- components info
-
getDeserializerBinding
Checks forJsonbDeserializer
on aParameter
.- Parameters:
parameter
- parameter not null- Returns:
- components info
-
getAdapterBinding
Checks forJsonbAdapter
on aParameter
.- Parameters:
parameter
- parameter not null- Returns:
- components info
-
getDeserializerBinding
Checks forJsonbDeserializer
on a type.- Parameters:
clsElement
- type not null- Returns:
- components info
-
getSerializerBinding
Checks forJsonbSerializer
on a property.- Parameters:
property
- property not null- Returns:
- components info
-
getSerializerBinding
Checks forJsonbSerializer
on a type.- Parameters:
clsElement
- type not null- Returns:
- components info
-
isPropertyNillable
Checks if property is nillable. Looks forJsonbProperty
nillable 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 forJsonbPropertyOrder
annotation.- 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 anyJsonbTransient
annotation defined for it- Returns:
- Set of
AnnotationTarget
s specifying in which scope theJsonbTransient
is applied
-
getJsonbDateFormatCategorized
SearchJsonbDateFormat
on property, if not found looks at annotations declared on property type class.- Parameters:
property
- Property to search on.- Returns:
- Map of
JsonbDateFormatter
instances 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 forJsonbDateFormat
annotation 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 forJsonbNumberFormat
annotation on java class.- Parameters:
clazzElement
- class to search not null- Returns:
- formatter to use
-
getJsonNumberFormatter
SearchJsonbNumberFormat
on property, if not found looks at annotations declared on property type class.- Parameters:
property
- Property to search on.- Returns:
- Map of
JsonbNumberFormatter
instances 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
ReturnsJsonbNumberFormatter
instance ifJsonbNumberFormat
annotation is present.- Parameters:
param
- annotated method parameter- Returns:
- formatter instance if
JsonbNumberFormat
is present otherwise null
-
getConstructorDateFormatter
ReturnsJsonbDateFormatter
instance ifJsonbDateFormat
annotation is present.- Parameters:
param
- annotated method parameter- Returns:
- formatter instance if
JsonbDateFormat
is present otherwise null
-
getPropertyVisibilityStrategy
public jakarta.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 withJsonbTransient
annotation.- Parameters:
target
- target to check
-
collectInterfaces
Get class interfaces recursively.- Parameters:
cls
- Class to process.- Returns:
- A list of all class interfaces.
-
introspectCustomization
public ClassCustomization introspectCustomization(JsonbAnnotatedElement<Class<?>> clsElement, ClassCustomization parentCustomization, jakarta.json.bind.config.PropertyNamingStrategy propertyNamingStrategy) Processes customizations.- Parameters:
clsElement
- Element to process.propertyNamingStrategy
- The naming strategy to use for the $JsonbConstructor
annotation, if set and noJsonbProperty
annotations are present.- Returns:
- Populated
ClassCustomization
instance.
-
getImplementationClass
Returns class ifImplementationClass
annotation is present.- Parameters:
property
- annotated property- Returns:
- Class if
ImplementationClass
is 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.
-
requiredParameters
public boolean requiredParameters(Executable executable, JsonbAnnotatedElement<Parameter> annotated)
-