Class FieldAccessorChain

java.lang.Object
org.litebridgedb.tracking.FieldAccessorChain
All Implemented Interfaces:
FieldAccessor

public final class FieldAccessorChain extends Object implements FieldAccessor
Represents a chain of FieldAccessor instances, allowing the traversal and manipulation of nested fields of a data transfer object (DTO).

This class provides mechanisms to navigate nested structures while enabling read/write access to the chained fields.

  • Constructor Details

  • Method Details

    • fieldPath

      public String fieldPath()
    • fieldAccessors

      public List<FieldAccessor> fieldAccessors()
    • subChain

      public FieldAccessorChain subChain()
    • add

      public FieldAccessorChain add(FieldAccessor fieldAccessor)
    • isLast

      public boolean isLast(FieldAccessor fieldAccessor)
    • name

      public String name()
      Description copied from interface: FieldAccessor
      Return the name of the field or property represented by this FieldAccessor.
      Specified by:
      name in interface FieldAccessor
      Returns:
      the name of the field or property as a String
    • get

      public @Nullable Object get(Object dto)
      Description copied from interface: FieldAccessor
      Retrieve the value of a field or property from the provided data transfer object (DTO).
      Specified by:
      get in interface FieldAccessor
      Parameters:
      dto - the data transfer object from which to retrieve the field or property value. Must not be null and should conform to the structure expected by this FieldAccessor.
      Returns:
      the value of the field or property, or null if the field value is null or could not be accessed.
    • set

      public void set(Object dto, @Nullable Object value)
      Description copied from interface: FieldAccessor
      Set the value of a field or property for the provided data transfer object (DTO).
      Specified by:
      set in interface FieldAccessor
      Parameters:
      dto - the data transfer object for which the field or property value will be set. Must not be null and should conform to the structure expected by this FieldAccessor.
      value - the value to set for the field or property. May be null if the field or property allows null values.
    • type

      public Class<?> type()
      Description copied from interface: FieldAccessor
      Returns the declared type for the field represented by this FieldAccessor.
      Specified by:
      type in interface FieldAccessor
      Returns:
      the field type
    • genericTypes

      public Class<?>[] genericTypes()
      Description copied from interface: FieldAccessor
      Returns an array of Class objects representing the generic types associated with the field or property represented by this FieldAccessor.
      Specified by:
      genericTypes in interface FieldAccessor
      Returns:
      an array of Class objects that represent the generic types of the field or property, or an empty array if the field or property does not use generics.
    • dtoClass

      public Class<?> dtoClass()
      Description copied from interface: FieldAccessor
      Retrieves the parent Class of the DTO containing the field targeted by this FieldAccessor.
      Specified by:
      dtoClass in interface FieldAccessor
      Returns:
      The parent DTO type
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object