public String getObjectTitle ( final Graph graph , final Node sub ) { if ( sub == null ) { return "" ; } final Optional < String > title = TITLE_PROPERTIES . stream ( ) . map ( Property :: asNode ) . flatMap ( p -> listObjects ( graph , sub , p ) . toList ( ) . stream ( ) ) . filter ( Node :: isLiteral ) . map ( Node :: getLiteral ) . map ( LiteralLabel :: toString ) . findFirst ( ) ; return title . orElse ( sub . isURI ( ) ? sub . getURI ( ) : sub . isBlank ( ) ? sub . getBlankNodeLabel ( ) : sub . toString ( ) ) ; }
Get the canonical title of a subject from the graph