@ Override public void listInsertBefore ( final T currentElement , final T newElement ) throws FrameworkException { if ( currentElement . getUuid ( ) . equals ( newElement . getUuid ( ) ) ) { throw new IllegalStateException ( "Cannot link a node to itself!" ) ; } final T previousElement = listGetPrevious ( currentElement ) ; if ( previousElement == null ) { linkNodes ( getSiblingLinkType ( ) , newElement , currentElement ) ; } else { // delete old relationship unlinkNodes ( getSiblingLinkType ( ) , previousElement , currentElement ) ; // dont create self link if ( ! previousElement . getUuid ( ) . equals ( newElement . getUuid ( ) ) ) { linkNodes ( getSiblingLinkType ( ) , previousElement , newElement ) ; } // dont create self link if ( ! newElement . getUuid ( ) . equals ( currentElement . getUuid ( ) ) ) { linkNodes ( getSiblingLinkType ( ) , newElement , currentElement ) ; } } }
Inserts newElement before currentElement in the list defined by this LinkedListManager .