public void addExistingItem ( final ItemsNodeInterval newNode ) { Preconditions . checkState ( newNode . getItems ( ) . size ( ) == 1 , "Invalid node=%s" , newNode ) ; final Item item = newNode . getItems ( ) . get ( 0 ) ; addNode ( newNode , new AddNodeCallback ( ) { @ Override public boolean onExistingNode ( final NodeInterval existingNode ) { final ItemsInterval existingOrNewNodeItems = ( ( ItemsNodeInterval ) existingNode ) . getItemsInterval ( ) ; existingOrNewNodeItems . add ( item ) ; // There is no new node added but instead we just populated the list of items for the already existing node return false ; } @ Override public boolean shouldInsertNode ( final NodeInterval insertionNode ) { // Always want to insert node in the tree when we find the right place. return true ; } } ) ; }
Add existing item into the tree