instanceof versus canAs

2023-08-25 Thread Steve Vestal
In some places I use e.g. (resource instanceof Individual) , but in others it seems I need resource.canAs(Individual.class).  If you have brief guidelines on when to use what, I would appreciate that.  A specific case is punning in an OntModel.  Is that a case where canAs(Individual.class

Re: instanceof

2016-10-02 Thread Andy Seaborne
instanceof applies to Java classes. It is a feature of the programming language. To see if an instance is of data-declared class, which is a separate concept, use getOntClass, hasOntClass or listOntClass methods on Individual. On 02/10/16 21:55, tina sani wrote: I have Employee class

instanceof

2016-10-02 Thread tina sani
); OntClass tech = model.getOntClass(ns + "Technicals"); OntClass emp = model.getOntClass(ns + "Employee"); Individual ind = tech.createIndividual(ns + "Bob"); I am trying like below but it flush an error message. if (ind instanceof tech){}