[jira] [Commented] (CLI-120) equals and hashCode are incomplete
[ https://issues.apache.org/jira/browse/CLI-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13157214#comment-13157214 ] Holger S. commented on CLI-120: --- I implemented equals and hashCode for ArgumentImpl and SourceDestImpl and created test cases. Please review this patch. a few issues arose: - Validators usually don't implement equals and hashCode either, so ArgumentImpl.equals does not work correctly if only the validator is different - PropertyOption does not have any attributes that are not used in OptionImpl.equals, so all are compared but I think it would fail if two different subclasses of OptionImpl were compared. I couldn't create a test case, but this could be a problem in the future. equals and hashCode are incomplete -- Key: CLI-120 URL: https://issues.apache.org/jira/browse/CLI-120 Project: Commons CLI Issue Type: Improvement Components: CLI-2.x Reporter: Andrew Shirley Priority: Minor Fix For: 2.0 Attachments: ArgumentEqualsPatch.diff there are many classes with equals and hashCode implemented however there are also classes which don't. We need to be consistent and if we are using equals then we need to define it for all classes in the affected hierarchy. For example OptionImpl has an equals but ParentImpl which extends OptionImpl and has several new members doesn't. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CLI-120) equals and hashCode are incomplete
[ https://issues.apache.org/jira/browse/CLI-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13149310#comment-13149310 ] Holger S. commented on CLI-120: --- Hello, I would like to implement the equals method for a few classes. I suggest to implement the methods strightforwardly by calling .equals on all members (or using == if primitive) and returning the ANDed result. Are there any classes where this approach might fail? Is it possible to implement the hashCode method for the other classes like in OptionImpl? I am not experienced in implementing hashCode so I am not sure, whether that approach is possible for all classes. This is a part of a lecture assignment, so I would be very grateful for quick responses :-) Regards, Holger equals and hashCode are incomplete -- Key: CLI-120 URL: https://issues.apache.org/jira/browse/CLI-120 Project: Commons CLI Issue Type: Improvement Components: CLI-2.x Reporter: Andrew Shirley Priority: Minor Fix For: 2.0 there are many classes with equals and hashCode implemented however there are also classes which don't. We need to be consistent and if we are using equals then we need to define it for all classes in the affected hierarchy. For example OptionImpl has an equals but ParentImpl which extends OptionImpl and has several new members doesn't. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira