gumbo.util.relation
Class TreeNodes.TreeNodeImm

java.lang.Object
  |
  +--gumbo.util.Delegatables.DelegatableImm
        |
        +--gumbo.util.relation.Relations.RelationImm
              |
              +--gumbo.util.relation.TreeNodes.TreeNodeImm
All Implemented Interfaces:
Delegatable, Disposable, Relation, java.io.Serializable, TreeNode
Enclosing class:
TreeNodes

public static class TreeNodes.TreeNodeImm
extends Relations.RelationImm
implements TreeNode, java.io.Serializable

A serializable immutable view wrapper for a target TreeNode. All accessors, including identity, forward to the target. All mutators throw an UnsupportedOperationException.

See Also:
Serialized Form

Constructor Summary
TreeNodes.TreeNodeImm(TreeNode target)
           
 
Method Summary
 void addChild(int index, TreeNode child)
          Adds a child to this parent.
 void addChild(TreeNode child)
          Adds a child to this parent.
 TreeNode findTreeNode(java.lang.Object delegator)
          Convenience method for getting the tree node corresponding to a delegator in this tree node's relationship.
 Group getChildren()
          Gets an immutable view of this parent's children.
 java.lang.Object getParent()
          Gets the parent of this child relation.
 boolean hasChildren()
          Returns true if this parent has any children, false if none.
 void implSetParent(TreeNode parent)
          Used by the system to mutually set the parent of this child.
 void removeChild(TreeNode child)
          Removes a child from this parent, and makes the child an orphan.
 
Methods inherited from class gumbo.util.relation.Relations.RelationImm
canFindRelation, dispose, findRelation, getAddedConnectionOut, getRelationship, getRemovingConnectionOut, implReadConnections, implWriteConnections, isDisposed, setRelationship
 
Methods inherited from class gumbo.util.Delegatables.DelegatableImm
getDelegator, initDelegator, isDelegatorInited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gumbo.util.relation.Relation
canFindRelation, findRelation, getAddedConnectionOut, getRelationship, getRemovingConnectionOut, implReadConnections, implWriteConnections, setRelationship
 
Methods inherited from interface gumbo.util.Disposable
dispose, isDisposed
 
Methods inherited from interface gumbo.util.Delegatable
getDelegator, initDelegator, isDelegatorInited
 

Constructor Detail

TreeNodes.TreeNodeImm

public TreeNodes.TreeNodeImm(TreeNode target)
Parameters:
target - Wrapped target. Never null.
Method Detail

getParent

public java.lang.Object getParent()
Description copied from interface: TreeNode
Gets the parent of this child relation.

Specified by:
getParent in interface TreeNode
Returns:
Parent delegator. Null if none (an orphan child).

addChild

public void addChild(TreeNode child)
Description copied from interface: TreeNode
Adds a child to this parent. The child must be an orphan (no parent). If the children store is a list the child is added to the end. Unless otherwise noted, the parent and child must be in the same relationship, the connect change is type TreeNodeConnection.

Specified by:
addChild in interface TreeNode
Parameters:
child - Child relation. Never null. Unless otherwise noted, duplicates are the same as a new child. Note that a SetList children store will throw an exception for duplicates.

addChild

public void addChild(int index,
                     TreeNode child)
Description copied from interface: TreeNode
Adds a child to this parent. The child must be an orphan (no parent). The child is inserted at a given position in the child list, with children at and after this position being shifted towards the end. Unless otherwise noted, the parent and child must be in the same relationship.

Specified by:
addChild in interface TreeNode
Parameters:
index - List index (>=0, <=size). If <0, same as addChild(Object) regardless of children store type.
child - Child relation. Never null. Unless otherwise noted, duplicates are ignored. Note that a SetList children store will throw an exception for duplicates.

removeChild

public void removeChild(TreeNode child)
Description copied from interface: TreeNode
Removes a child from this parent, and makes the child an orphan. Unless otherwise noted, the parent and child will remain in the same relationship.

Specified by:
removeChild in interface TreeNode
Parameters:
child - Child relation. Never null. Unless otherwise noted, a missing child is ignored.

hasChildren

public boolean hasChildren()
Description copied from interface: TreeNode
Returns true if this parent has any children, false if none.

Specified by:
hasChildren in interface TreeNode
Returns:
The result.

getChildren

public Group getChildren()
Description copied from interface: TreeNode
Gets an immutable view of this parent's children. When possible, use hasChildren() instead of this view to minimize lazy builds.

Specified by:
getChildren in interface TreeNode
Returns:
The non-null child delegators (Object). Never null. Unless otherwise noted, this is a singleton immutable view.

findTreeNode

public TreeNode findTreeNode(java.lang.Object delegator)
Description copied from interface: TreeNode
Convenience method for getting the tree node corresponding to a delegator in this tree node's relationship.

Specified by:
findTreeNode in interface TreeNode
Parameters:
delegator - The delegator. Never null.
Returns:
The delegator's tree node. Never null.

implSetParent

public void implSetParent(TreeNode parent)
Description copied from interface: TreeNode
Used by the system to mutually set the parent of this child. By convention, performs checking but affects no other state.

Specified by:
implSetParent in interface TreeNode
Parameters:
parent - Parent relation. Null if none (orphan).