public void addChild ( final DiffNode node ) { if ( node == this ) { throw new IllegalArgumentException ( "Detected attempt to add a node to itself. " + "This would cause inifite loops and must never happen." ) ; } else if ( node . isRootNode ( ) ) { throw new IllegalArgumentException ( "Detected attempt to add root node as child. " + "This is not allowed and must be a mistake." ) ; } else if ( node . getParentNode ( ) != null && node . getParentNode ( ) != this ) { throw new IllegalArgumentException ( "Detected attempt to add child node that is already the " + "child of another node. Adding nodes multiple times is not allowed, since it could " + "cause infinite loops." ) ; } if ( node . getParentNode ( ) == null ) { node . setParentNode ( this ) ; } children . put ( node . getElementSelector ( ) , node ) ; if ( state == State . UNTOUCHED && node . hasChanges ( ) ) { state = State . CHANGED ; } }
Adds a child to this node and sets this node as its parent node .