Class TreeNode.CollectionElement

All Implemented Interfaces:
TreeTable.Node
Enclosing class:
TreeNode

static final class TreeNode.CollectionElement extends TreeNode.Element
A node for an element in a collection. This class needs the iteration order to be stable.
  • Field Details

    • indexInList

      final int indexInList
      Index of the element in the collection, in iteration order.
  • Constructor Details

    • CollectionElement

      CollectionElement(TreeNode parent, Object metadata, PropertyAccessor accessor, int indexInData, int indexInList)
      Creates a new node for the given collection element.
      Parameters:
      parent - the parent of this node.
      metadata - the metadata object for which this node will be a value.
      accessor - accessor to use for fetching the name, type and collection.
      indexInData - index to be given to the accessor of fetching the collection.
      indexInList - index of the element in the collection, in iteration order.
  • Method Details

    • appendIdentifier

      void appendIdentifier(StringBuilder buffer)
      Appends an identifier for this node in the given buffer, for TreeNode.toString() implementation.
      Overrides:
      appendIdentifier in class TreeNode.Element
    • getIndex

      Integer getIndex()
      Returns the zero-based index of this node in the metadata property.
      Overrides:
      getIndex in class TreeNode
    • getName

      CharSequence getName()
      Appends the index of this property, if there is more than one. Index numbering begins at 1, since this name if for human reading.
      Overrides:
      getName in class TreeNode.Element
    • getUserObject

      public Object getUserObject()
      Fetches the property value from the metadata object, which is expected to be a collection, then fetch the element at the index represented by this node.
      Specified by:
      getUserObject in interface TreeTable.Node
      Overrides:
      getUserObject in class TreeNode.Element
      Returns:
      any object stored at this node by the user, or null if none.
    • setUserObject

      void setUserObject(Object value)
      Sets the property value for this node.
      Overrides:
      setUserObject in class TreeNode.Element
    • equals

      public boolean equals(Object other)
      Returns true if the value returned by getUserObject() should be the same for both nodes.
      Specified by:
      equals in interface TreeTable.Node
      Overrides:
      equals in class TreeNode.Element
      Parameters:
      other - the other object to compare with this node.
      Returns:
      whether the two objects are nodes with equal values and equal children, ignoring parents.
    • hashCode

      public int hashCode()
      Returns a hash code value for this node.
      Specified by:
      hashCode in interface TreeTable.Node
      Overrides:
      hashCode in class TreeNode.Element
      Returns:
      a hash code for this node, potentially based on values and children but ignoring parent.