-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.1.4
-
Fix Version/s: 2.1.5, 2.2.0-beta-1
-
Component/s: ast builder
-
Labels:None
-
Environment:Groovy Version: 2.1.4 JVM: 1.7.0_11 Vendor: Oracle Corporation OS: Linux
I am using the @Immutable annotation and need to customize the @EqualsAndHashCode fields. If the @Immutable annotation appears first it doesn't work. However, if I place @EqualsAndHashCode first it works.
@Canonical works correctly regardless of what order the annotations appear.
import groovy.transform.* @EqualsAndHashCode(includes = ['id']) @Immutable class A { String id String name } @Immutable @EqualsAndHashCode(includes = ['id']) class B { String id String name } def a1 = new A('1', 'foo') def a2 = new A('1', 'foo2') assert a1.equals(a2) assert a2.equals(a1) def b1 = new B('1', 'foo') def b2 = new B('1', 'foo2') assert b1.equals(b2) // fails assert b2.equals(b1) // fails