Simple answer:
inMemModel.removeAll(null, RDF.value, ResourceFactory.createPlainLiteral("class"));
This will delete all triples where the predicate is rdf:value and the object is "class" .
Inside - at the SPI level you tried - you could use inMemModel.remove(Node.ANY, nodePredicate, nodeObject) , which finds and removes (using delete ) the corresponding triples. delete takes the main triple and therefore does not find find.
createAnon() does not work simply because it is a different object, so do not delete anything.
source share