@ SuppressWarnings ( "unchecked" ) public OGraphEdge link ( final OGraphVertex iTargetVertex , final String iClassName ) { if ( iTargetVertex == null ) throw new IllegalArgumentException ( "Missed the target vertex" ) ; // CREATE THE EDGE BETWEEN ME AND THE TARGET final OGraphEdge edge = new OGraphEdge ( database , iClassName , this , iTargetVertex ) ; getOutEdges ( ) . add ( edge ) ; Set < ODocument > recordEdges = ( ( Set < ODocument > ) document . field ( OGraphDatabase . VERTEX_FIELD_OUT ) ) ; if ( recordEdges == null ) { recordEdges = new HashSet < ODocument > ( ) ; document . field ( OGraphDatabase . VERTEX_FIELD_OUT , recordEdges ) ; } recordEdges . add ( edge . getDocument ( ) ) ; document . setDirty ( ) ; // INSERT INTO THE INGOING EDGES OF TARGET iTargetVertex . getInEdges ( ) . add ( edge ) ; recordEdges = ( ( Set < ODocument > ) iTargetVertex . getDocument ( ) . field ( OGraphDatabase . VERTEX_FIELD_IN ) ) ; if ( recordEdges == null ) { recordEdges = new HashSet < ODocument > ( ) ; iTargetVertex . getDocument ( ) . field ( OGraphDatabase . VERTEX_FIELD_IN , recordEdges ) ; } recordEdges . add ( edge . getDocument ( ) ) ; iTargetVertex . getDocument ( ) . setDirty ( ) ; return edge ; }
Create a link between the current vertex and the target one . The link is of type iClassName .