java.lang.Object
org.eclipse.yasson.internal.model.PropertyModel
- All Implemented Interfaces:
Comparable<PropertyModel>
A model for class property.
Property is JavaBean alike meta information field / getter / setter of a property in class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassModel
Model of the class this field belongs to.private final PropertyCustomization
Customization of this property.private final Field
private final Method
private final Type
private final MethodHandle
private static final MethodHandles.Lookup
private final Property
private final String
Field propertyName as in class by java bean convention.private final Type
Field propertyType.private final String
Calculated name to be used when reading json document.private final Method
private final Type
private final MethodHandle
private final String
Calculated name to be used when writing json document. -
Constructor Summary
ConstructorsConstructorDescriptionPropertyModel
(ClassModel classModel, Property property, JsonbContext jsonbContext) Creates an instance.Create a new PropertyModel that merges two existing PropertyModel that have identical read/write names. -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
calculateReadWriteName
(String readWriteName, String propertyName, jakarta.json.bind.config.PropertyNamingStrategy strategy) If customized by JsonbPropertyAnnotation, than is used, otherwise use strategy to translate.int
private static MethodHandle
createReadHandle
(Field field, Method getter, boolean getterVisible, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) private static MethodHandle
createWriteHandle
(Field field, Method setter, boolean setterVisible, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) boolean
Model of declaring class of this property.Introspected customization of a property.getField()
Field of a javabean property.Setter of a javabean property.Returns which type should be used to deserialization.Default property name according to Field / Getter / Setter method names.Returns which type should be used to serialization.Gets a name of JSON document property to read this property from.Getter of a javabean property.private static <T> T
getTargetForMostPreciseScope
(Map<AnnotationTarget, T> collectedAnnotations, AnnotationTarget... targets) Pull result for most significant scope defined by order of annotation targets.private SerializerBinding<?>
getUserSerializerBinding
(Property property, JsonbContext jsonbContext) Gets property's value.int
hashCode()
private PropertyCustomization
introspectCustomization
(Property property, JsonbContext jsonbContext, ClassModel classModel) private static void
introspectDateFormatter
(Property property, AnnotationIntrospector introspector, PropertyCustomization.Builder builder, JsonbContext jsonbContext) private static void
introspectNumberFormatter
(Property property, AnnotationIntrospector introspector, PropertyCustomization.Builder builder) private static boolean
isFieldVisible
(Field field, Method method, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) private static boolean
isMethodVisible
(Method method, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) private static boolean
isNotPublicAndNonNested
(Class<?> declaringClass) static boolean
isPropertyReadable
(Field field, Method getter, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) boolean
Property is readable.private static boolean
isVisible
(Predicate<jakarta.json.bind.config.PropertyVisibilityStrategy> visibilityCheckFunction, Method method, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) Look up class and package level @JsonbVisibility, or global config PropertyVisibilityStrategy.boolean
Property is writable.private static void
overrideAccessible
(AccessibleObject accessibleObject) void
Sets a property.
-
Field Details
-
LOOKUP
-
propertyName
Field propertyName as in class by java bean convention. -
readName
Calculated name to be used when reading json document. -
writeName
Calculated name to be used when writing json document. -
propertyType
Field propertyType. -
classModel
Model of the class this field belongs to. -
property
-
customization
Customization of this property. -
getValueHandle
-
setValueHandle
-
field
-
getter
-
setter
-
getterMethodType
-
setterMethodType
-
-
Constructor Details
-
PropertyModel
Create a new PropertyModel that merges two existing PropertyModel that have identical read/write names. The input PropertyModel objects MUST be equal (a.equals(b) == true)- Parameters:
a
- a PropertyModel instance to mergeb
- the other PropertyModel instance to merge
-
PropertyModel
Creates an instance.- Parameters:
classModel
- Class model of declaring class.property
- Property.jsonbContext
- Context.
-
-
Method Details
-
getPropertyDeserializationType
Returns which type should be used to deserialization.- Returns:
- deserialization type
-
getPropertySerializationType
Returns which type should be used to serialization.- Returns:
- serialization type
-
getUserSerializerBinding
-
introspectCustomization
private PropertyCustomization introspectCustomization(Property property, JsonbContext jsonbContext, ClassModel classModel) -
introspectDateFormatter
private static void introspectDateFormatter(Property property, AnnotationIntrospector introspector, PropertyCustomization.Builder builder, JsonbContext jsonbContext) -
introspectNumberFormatter
private static void introspectNumberFormatter(Property property, AnnotationIntrospector introspector, PropertyCustomization.Builder builder) -
getTargetForMostPreciseScope
private static <T> T getTargetForMostPreciseScope(Map<AnnotationTarget, T> collectedAnnotations, AnnotationTarget... targets) Pull result for most significant scope defined by order of annotation targets.- Parameters:
collectedAnnotations
- all targetstargets
- ordered target types by scope
-
getValue
Gets property's value.- Parameters:
object
- object to read property from- Returns:
- property's value
-
setValue
Sets a property. If not writable (final, transient, static), ignores property.- Parameters:
object
- Object to set value in.value
- Value to set.
-
isReadable
public boolean isReadable()Property is readable. Based on access policy and java field modifiers.- Returns:
- true if can be serialized to JSON
-
isWritable
public boolean isWritable()Property is writable. Based on access policy and java field modifiers.- Returns:
- true if can be deserialized from JSON
-
getPropertyName
Default property name according to Field / Getter / Setter method names. This name is use for identifying properties, for JSON serialization is used customized name which may be derived from default name.- Returns:
- default name
-
getClassModel
Model of declaring class of this property.- Returns:
- class model
-
getCustomization
Introspected customization of a property.- Returns:
- immutable property customization
-
compareTo
- Specified by:
compareTo
in interfaceComparable<PropertyModel>
-
equals
-
hashCode
public int hashCode() -
getReadName
Gets a name of JSON document property to read this property from.- Returns:
- Name of JSON document property.
-
getWriteName
-
calculateReadWriteName
private static String calculateReadWriteName(String readWriteName, String propertyName, jakarta.json.bind.config.PropertyNamingStrategy strategy) If customized by JsonbPropertyAnnotation, than is used, otherwise use strategy to translate. Since this is cached for performance reasons strategy has to be consistent with calculated values for same input. -
getField
Field of a javabean property.- Returns:
field
-
getGetter
Setter of a javabean property.- Returns:
getter
-
getSetter
Getter of a javabean property.- Returns:
setter
-
isPropertyReadable
-
createReadHandle
private static MethodHandle createReadHandle(Field field, Method getter, boolean getterVisible, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) -
createWriteHandle
private static MethodHandle createWriteHandle(Field field, Method setter, boolean setterVisible, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) -
isFieldVisible
-
isNotPublicAndNonNested
-
isMethodVisible
private static boolean isMethodVisible(Method method, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) -
overrideAccessible
-
isVisible
private static boolean isVisible(Predicate<jakarta.json.bind.config.PropertyVisibilityStrategy> visibilityCheckFunction, Method method, jakarta.json.bind.config.PropertyVisibilityStrategy strategy) Look up class and package level @JsonbVisibility, or global config PropertyVisibilityStrategy. If any is found it is used for resolving visibility by calling provided visibilityCheckFunction.- Parameters:
visibilityCheckFunction
- function declaring visibility check- Returns:
- Optional with result of visibility check, or empty optional if no strategy is found
-
getGetValueHandle
-
getSetValueHandle
-