Is it possible to find out whether two instances are of the same class, programmatically (Using api such as JENA)
If the two objects have the same values, equals() will return true . In the second comparison, equals() checks to see whether the passed object is null, or if it's typed as a different class. If it's a different class then the objects are not equal.
The referential equality (using === , == or Object.is() ) determines whether the operands are the same object instance.
An rdf:Bag is used to indicate that the container is intended to be unordered. An rdf:Seq is used to indicate that the order indicated by the numerical order of the container membership properties of the container is intended to be significant.
Easy in SPARQL:
ASK { <instance1> a ?class . <instance2> a ?class . }
In Jena API:
boolean shareClass = false;
for (Statement s: instance1.listProperties(RDF.type)) {
if (instance2.hasProperty(RDF.type, s.getObject()) {
shareClass = true;
break;
}
}
Not very elegant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With