public static Function < Resource , Optional < String > > resourceToProperty ( final Session session ) { return resource -> { try { final NamespaceRegistry registry = getNamespaceRegistry ( session ) ; return Optional . of ( registry . getPrefix ( resource . getNameSpace ( ) ) + ":" + resource . getLocalName ( ) ) ; } catch ( final RepositoryException ex ) { LOGGER . debug ( "Could not resolve resource namespace ({}): {}" , resource . toString ( ) , ex . getMessage ( ) ) ; } return empty ( ) ; } ; }
Using a JCR session return a function that maps an RDF Resource to a corresponding property name .