Class NodeImpl

  • All Implemented Interfaces:
    Node

    public class NodeImpl
    extends java.lang.Object
    implements Node
    The default implementation of Node
    • Field Detail

      • asset

        private Asset asset
        The asset this node holds.
      • children

        private java.util.Set<Node> children
        The children nodes.
    • Constructor Detail

      • NodeImpl

        public NodeImpl​(ArchivePath path)
        Constructor This constructor will create a directory Node with the specified path.
        Parameters:
        path - The ArchivePath this Node is placed within the Archive
      • NodeImpl

        public NodeImpl​(ArchivePath path,
                        Asset asset)
        Constructor This constructor will create an asset Node with the specified path.
        Parameters:
        path - The ArchivePath this Node is placed within the Archive
        asset - The Asset that this Node holds.
    • Method Detail

      • getPath

        public ArchivePath getPath()
        Specified by:
        getPath in interface Node
        Returns:
        The path where this node is placed within the Archive
      • getAsset

        public Asset getAsset()
        Specified by:
        getAsset in interface Node
        Returns:
        The Asset this node holds, null if it is an empty directory
      • getChildren

        public java.util.Set<Node> getChildren()
        Specified by:
        getChildren in interface Node
        Returns:
        The child nodes of this node or, an empty set if it has no children or holds an asset. This method will never return null. The returned Set will be an immutable view.
      • addChild

        public void addChild​(Node node)
        Adds a child to the Set of nodes. If already exists, nothing happens.
        Parameters:
        node - The Node that will be added as a child
      • removeChild

        public void removeChild​(Node node)
        Removes a child from the Set of nodes. If it doesn't exists, nothing happens.
        Parameters:
        node - The Node that will be removed from the childs
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object