Class PropertyModel

java.lang.Object
org.eclipse.yasson.internal.model.PropertyModel
All Implemented Interfaces:
Comparable<PropertyModel>

public final class PropertyModel extends Object implements Comparable<PropertyModel>
A model for class property. Property is JavaBean alike meta information field / getter / setter of a property in class.
  • Field Details

    • LOOKUP

      private static final MethodHandles.Lookup LOOKUP
    • propertyName

      private final String propertyName
      Field propertyName as in class by java bean convention.
    • readName

      private final String readName
      Calculated name to be used when reading json document.
    • writeName

      private final String writeName
      Calculated name to be used when writing json document.
    • propertyType

      private final Type propertyType
      Field propertyType.
    • classModel

      private final ClassModel classModel
      Model of the class this field belongs to.
    • property

      private final Property property
    • customization

      private final PropertyCustomization customization
      Customization of this property.
    • getValueHandle

      private final MethodHandle getValueHandle
    • setValueHandle

      private final MethodHandle setValueHandle
    • field

      private final Field field
    • getter

      private final Method getter
    • setter

      private final Method setter
    • getterMethodType

      private final Type getterMethodType
    • setterMethodType

      private final Type setterMethodType
  • Constructor Details

    • PropertyModel

      public PropertyModel(PropertyModel a, PropertyModel b)
      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 merge
      b - the other PropertyModel instance to merge
    • PropertyModel

      public PropertyModel(ClassModel classModel, Property property, JsonbContext jsonbContext)
      Creates an instance.
      Parameters:
      classModel - Class model of declaring class.
      property - Property.
      jsonbContext - Context.
  • Method Details

    • getPropertyDeserializationType

      public Type getPropertyDeserializationType()
      Returns which type should be used to deserialization.
      Returns:
      deserialization type
    • getPropertySerializationType

      public Type getPropertySerializationType()
      Returns which type should be used to serialization.
      Returns:
      serialization type
    • getUserSerializerBinding

      private SerializerBinding<?> getUserSerializerBinding(Property property, JsonbContext jsonbContext)
    • 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 targets
      targets - ordered target types by scope
    • getValue

      public Object getValue(Object object)
      Gets property's value.
      Parameters:
      object - object to read property from
      Returns:
      property's value
    • setValue

      public void setValue(Object object, Object value)
      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

      public String 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

      public ClassModel getClassModel()
      Model of declaring class of this property.
      Returns:
      class model
    • getCustomization

      public PropertyCustomization getCustomization()
      Introspected customization of a property.
      Returns:
      immutable property customization
    • compareTo

      public int compareTo(PropertyModel o)
      Specified by:
      compareTo in interface Comparable<PropertyModel>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getReadName

      public String getReadName()
      Gets a name of JSON document property to read this property from.
      Returns:
      Name of JSON document property.
    • getWriteName

      public String 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

      public Field getField()
      Field of a javabean property.
      Returns:
      field
    • getGetter

      public Method getGetter()
      Setter of a javabean property.
      Returns:
      getter
    • getSetter

      public Method getSetter()
      Getter of a javabean property.
      Returns:
      setter
    • isPropertyReadable

      public static boolean isPropertyReadable(Field field, Method getter, jakarta.json.bind.config.PropertyVisibilityStrategy strategy)
    • 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

      private static boolean isFieldVisible(Field field, Method method, jakarta.json.bind.config.PropertyVisibilityStrategy strategy)
    • isNotPublicAndNonNested

      private static boolean isNotPublicAndNonNested(Class<?> declaringClass)
    • isMethodVisible

      private static boolean isMethodVisible(Method method, jakarta.json.bind.config.PropertyVisibilityStrategy strategy)
    • overrideAccessible

      private static void overrideAccessible(AccessibleObject accessibleObject)
    • 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

      public MethodHandle getGetValueHandle()
    • getSetValueHandle

      public MethodHandle getSetValueHandle()