Interface ObjectMember


  • @API(status=EXPERIMENTAL)
    public interface ObjectMember
    A pointer to a class member belonging to a certain object instance. Allows to read and modify the member's value in place.
    Author:
    Simon Taddiken
    See Also:
    ObjectTraversal
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.Object> collectionParent()
      If parent() has been discovered in a supported collection type (array, Iterable, Collection, Map) this method returns the respective collection.
      default boolean hasTypeCompatibleTo​(java.lang.Class<?> type)  
      boolean isReadonly()  
      boolean isWriteOnly()  
      java.lang.String name()
      The canonical name of the member.
      java.lang.Object parent()
      The object of which this is a direct child attribute.
      void setValue​(java.lang.Object value)
      Sets the member's value to the respective value.
      java.lang.Object value()
      Reads the member's value.
      java.lang.Class<?> valueType()
      The type of this member.
    • Method Detail

      • parent

        java.lang.Object parent()
        The object of which this is a direct child attribute.
        Returns:
        Our parent.
      • collectionParent

        java.util.Optional<java.lang.Object> collectionParent()
        If parent() has been discovered in a supported collection type (array, Iterable, Collection, Map) this method returns the respective collection.

        Note that, during traversal, only the first occurrence of an object instance is taken into account. If the same object is once referenced in a collection and once directly, then depending on attribute discovery order, you might or might not encounter the one with available collection parent.

        Returns:
        Pointer to the collection in which parent() has been discovered while traversing an object graph.
      • name

        java.lang.String name()
        The canonical name of the member.
        Returns:
        The name.
      • hasTypeCompatibleTo

        default boolean hasTypeCompatibleTo​(java.lang.Class<?> type)
      • valueType

        java.lang.Class<?> valueType()
        The type of this member.
        Returns:
        The type.
      • value

        java.lang.Object value()
        Reads the member's value. Whether reading the value is supported highly depends on the implementation. Implementations are advised to provide a best effort approach for determining the value without failure.

        If this member is isWriteOnly() null is returned.

        Returns:
        The value (may be null)
        Throws:
        java.lang.UnsupportedOperationException - If reading the value fails.
      • setValue

        void setValue​(java.lang.Object value)
        Sets the member's value to the respective value. Whether setting the value is supported highly depends on the implementation. If the member is isReadonly(), nothing happens.
        Parameters:
        value - The value to set (may be null)
        Throws:
        java.lang.UnsupportedOperationException - If setting the value is not possible.
      • isReadonly

        boolean isReadonly()
      • isWriteOnly

        boolean isWriteOnly()