.equals in KMF
brice-morin opened this issue · 4 comments
Is there a particular (I mean, useful) semantic on the .equals
in KMF? Or is it stupidly mapped to java.lang.Object.equals
(i.e. not overidden), which itself is basically mapped to Java's ==
, which is not so useful in practice, e.g. if I am comparing two models (having of course all their elements !=
...)
My typical use case: I basically want to test that KMF loaders and serializers work as they should i.e. (in pseudo-code)
myModel = load(...)
save(myModel, ...)
myNewModel = load(...)
assertTrue(myModel.equals(myNewModel))//should be true, if loader and serializer work fine
I am of course not interested in testing:
assertTrue(myModel == myNewModel)//will always be false, since objects are distincts, but equals (in principle)
with ==
to be interpreted in the Java sense
A good source of inspiration might be:
https://code.google.com/p/deep-equals/source/browse/deep-equals/java/com/cedarsoftware/util/DeepEquals.java
Of course, the generative approach of KMF should avoid all those reflexive calls, since we now exactly what we want to compare :-)
I am very happy for now, but might come back some time soon on that topic :-)