-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow mixed-type equals #249
Comments
If we go for mixed-type equality, can we assure that all (future) implementation of an interface like
|
We can't control how people implement their equals, but all we can is to provide examples and sample test cases to guide them through a correct implementation.
I also think so. In this case, I need to modify also the current PR if we want to have such behaviour. |
Another possible solution for this problem would be to add a method similar to However, this would not answer the question if we should change how equals work in AAS4J (or in certain classes at least). |
I created a separate issue for the PR #248 and allowing mixed-type equals which also mentioned in the community meeting:
https://www.eclipse.org/lists/aas4j-dev/msg00041.html
Metamodel elements defined as interfaces (like
public interface Property extends DataElement
) and aas4j allows to have various concrete implementation. The most important advantage is to allow someone to have a more efficient implementation (use linked list instead of array list, or keep some internal states for more efficient navigations,...). However, if we have different implementation of an entity (e.g.Property
), should we allowed to compare them?The mentioned article shed lights on many logical challenges:
http://www.angelikalanger.com/Articles/JavaSolutions/SecretsOfEquals/Equals-2.html
As mentioned in the article not allowing mixed-type makes life easier. But we can also see other examples that allow it.
As an example the
equals
for javaArrayList
allows any subtype of List for comparison. So you can compare LinkedList with ArrayList.So the most important thing is to define a clear logic and semantic as it might get very tricky.
For example we have
AnnotatedRelationshipElement
andRelationshipElement
. Shouldequals
be always false? or ifAnnotatedRelationshipElement
has no annotation, then it can be comparable toRelationshipElement
.The text was updated successfully, but these errors were encountered: