-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2165: Generated equals fails on annotated array type
- Loading branch information
Roel Spilker
authored and
Roel Spilker
committed
Jul 8, 2019
1 parent
11065b5
commit 6ed3b7c
Showing
4 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
test/transform/resource/after-delombok/EqualsAndHashCodeAnnotated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import java.lang.annotation.*; | ||
|
||
class EqualsAndHashCodeAnnotated { | ||
@Annotated | ||
int primitive; | ||
@Annotated | ||
Object object; | ||
int @Annotated [] primitiveValues; | ||
int @Annotated [] @Annotated [] morePrimitiveValues; | ||
Integer @Annotated [] objectValues; | ||
Integer @Annotated [] @Annotated [] moreObjectValues; | ||
@Target(ElementType.TYPE_USE) | ||
@Retention(RetentionPolicy.SOURCE) | ||
@interface Annotated { | ||
} | ||
@java.lang.Override | ||
@java.lang.SuppressWarnings("all") | ||
public boolean equals(final java.lang.Object o) { | ||
if (o == this) return true; | ||
if (!(o instanceof EqualsAndHashCodeAnnotated)) return false; | ||
final EqualsAndHashCodeAnnotated other = (EqualsAndHashCodeAnnotated) o; | ||
if (!other.canEqual((java.lang.Object) this)) return false; | ||
if (this.primitive != other.primitive) return false; | ||
final java.lang.Object this$object = this.object; | ||
final java.lang.Object other$object = other.object; | ||
if (this$object == null ? other$object != null : !this$object.equals(other$object)) return false; | ||
if (!java.util.Arrays.equals(this.primitiveValues, other.primitiveValues)) return false; | ||
if (!java.util.Arrays.deepEquals(this.morePrimitiveValues, other.morePrimitiveValues)) return false; | ||
if (!java.util.Arrays.deepEquals(this.objectValues, other.objectValues)) return false; | ||
if (!java.util.Arrays.deepEquals(this.moreObjectValues, other.moreObjectValues)) return false; | ||
return true; | ||
} | ||
@java.lang.SuppressWarnings("all") | ||
protected boolean canEqual(final java.lang.Object other) { | ||
return other instanceof EqualsAndHashCodeAnnotated; | ||
} | ||
@java.lang.Override | ||
@java.lang.SuppressWarnings("all") | ||
public int hashCode() { | ||
final int PRIME = 59; | ||
int result = 1; | ||
result = result * PRIME + this.primitive; | ||
final java.lang.Object $object = this.object; | ||
result = result * PRIME + ($object == null ? 43 : $object.hashCode()); | ||
result = result * PRIME + java.util.Arrays.hashCode(this.primitiveValues); | ||
result = result * PRIME + java.util.Arrays.deepHashCode(this.morePrimitiveValues); | ||
result = result * PRIME + java.util.Arrays.deepHashCode(this.objectValues); | ||
result = result * PRIME + java.util.Arrays.deepHashCode(this.moreObjectValues); | ||
return result; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
test/transform/resource/before/EqualsAndHashCodeAnnotated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//version 8 | ||
import java.lang.annotation.*; | ||
|
||
@lombok.EqualsAndHashCode | ||
class EqualsAndHashCodeAnnotated { | ||
@Annotated int primitive; | ||
@Annotated Object object; | ||
|
||
int @Annotated [] primitiveValues; | ||
int @Annotated [] @Annotated [] morePrimitiveValues; | ||
|
||
Integer @Annotated [] objectValues; | ||
Integer @Annotated [] @Annotated [] moreObjectValues; | ||
|
||
@Target(ElementType.TYPE_USE) | ||
@Retention(RetentionPolicy.SOURCE) | ||
@interface Annotated { | ||
} | ||
} |