All Known Subinterfaces:
ICallStackElement
All Known Implementing Classes:
CallStackElement

public interface ITree
A basic interface for a tree structure, ie hierarchical data where each node can be linked to a specific object.
Author:
Geneviève Bastien
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addChild(ITree child)
    Add a child to this tree object.
    Create a new element that is a copy of the current object.
    Get the children of this object
    static int
    Get the depth of this object, recursively with its children.
    Get the name of this tree element, it should be human-readable as it will be displayed to the user
    @Nullable ITree
    Get the parent of this tree element
    void
    setParent(@Nullable ITree parent)
    Set the parent of this tree object
  • Method Details

    • getName

      String getName()
      Get the name of this tree element, it should be human-readable as it will be displayed to the user
      Returns:
      The name of this tree element
    • getParent

      @Nullable ITree getParent()
      Get the parent of this tree element
      Returns:
      The parent of this object
    • getChildren

      Collection<ITree> getChildren()
      Get the children of this object
      Returns:
      A collection of children elements
    • addChild

      void addChild(ITree child)
      Add a child to this tree object. This method should make sure to set the parent of the child to the curent object
      Parameters:
      child - The child object
    • setParent

      void setParent(@Nullable ITree parent)
      Set the parent of this tree object
      Parameters:
      parent - The parent of the object, it can be null if there is no parent
    • copyElement

      ITree copyElement()
      Create a new element that is a copy of the current object. This copy should copy only the object's data, not the hierarchy as callers of this method may want to create a new hierarchy for those elements.
      Returns:
      a new element, copy of the current element
    • getDepth

      static int getDepth(ITree tree)
      Get the depth of this object, recursively with its children. An object with no children would have a depth of 1.
      Parameters:
      tree - The object for which to get the depth
      Returns:
      The depth