[
https://issues.apache.org/jira/browse/GROOVY-6151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-6151.
-----------------------------
> Equal on class (extends Map)
> ----------------------------
>
> Key: GROOVY-6151
> URL: https://issues.apache.org/jira/browse/GROOVY-6151
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 2.1.3
> Reporter: Grzegorz Karawacki
> Priority: Major
> Attachments: Main.groovy, TestError.groovy
>
>
> The problem occurs for classes inherit from class Map:
> {code:title=TestError.groovy|borderStyle=solid}
> class TestError extends HashMap {
> String id
> String getId() {
> return id
> }
> void setId(String id) {
> this.id = id
> }
> boolean equals(Object o) {
> if (this.is(o)) return true
> if (getClass() != o.class) return false
> if (!super.equals(o)) return false
> TestError testError = (TestError) o
> if (id != testError.id) return false
> return true
> }
> int hashCode() {
> int result = super.hashCode()
> result = 31 * result + (id != null ? id.hashCode() : 0)
> return result
> }
> }
> {code}
> {code:title=Main.groovy|borderStyle=solid}
> TestError t1 = new TestError()
> t1.setId("1")
> TestError t2 = new TestError()
> t2.setId("2")
> println(t1.getId())
> println(t2.getId())
> println(t1.equals(t2))
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)