Search Mailing List Archives
[protege-discussion] Class equality discussion on code generation feature
simon.paradies.ext at siemens.com
Mon Apr 6 02:42:51 PDT 2009
I really like the code generation feature for wrapping Protégé instances into Java objects.
However, I wonder why two Java Objects obtained by the factory and associated with the same individual are not the same in the sense of the java '==' operator. Example (PersonFactory and Person are generated by Protégé; its OWL but would apply to Frames as well):
JenaOWLModel owlModel = ProtegeOWL.createJenaOWLModelFromURI("file:///C:/temp/person.owl");
PersonFactory pf = new PersonFactory(owlModel);
Person jd = pf.createPerson("JonDoe");
Person jd1 = pf.getPerson("JonDoe");
Person jd2 = pf.getPerson("JonDoe");
RDFIndividual jdI1 = owlModel.getRDFIndividual("JonDoe");
RDFIndividual jdI2 = owlModel.getRDFIndividual("JonDoe");
System.out.println(jd1 == jd2);
System.out.println(jdI1 == jdI2);
I get the following output:
The generated pf.getPerson() every time creates a new wrapping object.
I presume that to let the first comparison to be true would require a bit of effort (holding pointers to the already generated objects).
Why this works for RDFIndividuals but not for generated classes? Any thoughts or design decisions?
More information about the protege-discussion