static void fillNodesToPrune ( Object input , final Map < String , Object > toPrune ) { // recurse through arrays if ( isArray ( input ) ) { for ( final Object i : ( List < Object > ) input ) { fillNodesToPrune ( i , toPrune ) ; } } else if ( isObject ( input ) ) { // skip @values if ( isValue ( input ) ) { return ; } // recurse through @lists if ( isList ( input ) ) { fillNodesToPrune ( ( ( Map < String , Object > ) input ) . get ( "@list" ) , toPrune ) ; return ; } // recurse through properties for ( final String prop : new LinkedHashSet <> ( ( ( Map < String , Object > ) input ) . keySet ( ) ) ) { if ( prop . equals ( JsonLdConsts . ID ) ) { final String id = ( String ) ( ( Map < String , Object > ) input ) . get ( JsonLdConsts . ID ) ; if ( id . startsWith ( "_:" ) ) { // if toPrune contains the id already, it was already // present somewhere else, // so we just null the value if ( toPrune . containsKey ( id ) ) { toPrune . put ( id , null ) ; } else { // else we add the object as the value toPrune . put ( id , input ) ; } } } else { fillNodesToPrune ( ( ( Map < String , Object > ) input ) . get ( prop ) , toPrune ) ; } } } else if ( input instanceof String ) { // this is an id, as non-id values will have been discarded by the // isValue() above final String p = ( String ) input ; if ( p . startsWith ( "_:" ) ) { // the id is outside of the context of an @id property, if we're // in that case, // then we're referencing a blank node id so this id should not // be removed toPrune . put ( p , null ) ; } } }
Gets the objects on which we ll prune the blank node ID