Entry parent = getParent(); if( parent == null ){ return;
Entry parent = getParent(); if( parent == null ){ return;
/** * Replaces <code>this</code> with <code>next</code>. * @param next the element which replaces this */ public void replace( Entry next ){ Entry parent = getParent(); if( parent == null ){ return; } if( parent instanceof Root ){ ((Root)parent).setChild( next ); } else{ Node parentNode = (Node)parent; if( parentNode.getChildA() == this ){ parentNode.setChildA( next ); } else{ parentNode.setChildB( next ); } } }
/** * Replaces <code>this</code> with <code>next</code>. * @param next the element which replaces this */ public void replace( Entry next ){ Entry parent = getParent(); if( parent == null ){ return; } if( parent instanceof Root ){ ((Root)parent).setChild( next ); } else{ Node parentNode = (Node)parent; if( parentNode.getChildA() == this ){ parentNode.setChildA( next ); } else{ parentNode.setChildB( next ); } } }
/** * Tells whether <code>anchestor</code> is an anchestor of this entry. * @param anchestor the item to search * @return <code>true</code> if <code>anchestor</code> is <code>this</code> or a * parent of <code>this</code> */ public boolean isAnchestor( Entry anchestor ){ Entry current = this; while( current != null ){ if( current == anchestor ){ return true; } current = current.getParent(); } return false; }
/** * Tells whether <code>anchestor</code> is an anchestor of this entry. * @param anchestor the item to search * @return <code>true</code> if <code>anchestor</code> is <code>this</code> or a * parent of <code>this</code> */ public boolean isAnchestor( Entry anchestor ){ Entry current = this; while( current != null ){ if( current == anchestor ){ return true; } current = current.getParent(); } return false; }