diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-11-18 12:45:02 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-11-18 13:04:09 +0100 |
commit | 3c47eb1299467f052f25581430d20bc3b2b83f4d (patch) | |
tree | 3bdc37b4324b185e0c907b421d389735193f20d9 /usage_examples/EqualsAndHashCodeExample_post.jpage | |
parent | 36f9a5aabc393738af1587907e324ea44661ed4d (diff) | |
download | lombok-3c47eb1299467f052f25581430d20bc3b2b83f4d.tar.gz lombok-3c47eb1299467f052f25581430d20bc3b2b83f4d.tar.bz2 lombok-3c47eb1299467f052f25581430d20bc3b2b83f4d.zip |
Added documentation for val and @Getter(lazy=true) and updated docs for Log and EqualsAndHashCode to reflect new lombok 0.10 features.
Diffstat (limited to 'usage_examples/EqualsAndHashCodeExample_post.jpage')
-rw-r--r-- | usage_examples/EqualsAndHashCodeExample_post.jpage | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usage_examples/EqualsAndHashCodeExample_post.jpage b/usage_examples/EqualsAndHashCodeExample_post.jpage index 312bb92f..189a520e 100644 --- a/usage_examples/EqualsAndHashCodeExample_post.jpage +++ b/usage_examples/EqualsAndHashCodeExample_post.jpage @@ -15,8 +15,9 @@ public class EqualsAndHashCodeExample { @Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; - if (o.getClass() != this.getClass()) return false; + if (!(o instanceof EqualsAndHashCodeExample)) return false; EqualsAndHashCodeExample other = (EqualsAndHashCodeExample) o; + if (!other.canEqual(this)) return false; if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false; if (Double.compare(this.score, other.score) != 0) return false; if (!Arrays.deepEquals(this.tags, other.tags)) return false; @@ -33,6 +34,10 @@ public class EqualsAndHashCodeExample { return result; } + public boolean canEqual(Object other) { + return other instanceof EqualsAndHashCodeExample; + } + public static class Square extends Shape { private final int width, height; @@ -44,9 +49,10 @@ public class EqualsAndHashCodeExample { @Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; - if (o.getClass() != this.getClass()) return false; - if (!super.equals(o)) return false; + if (!(o instanceof Square)) return false; Square other = (Square) o; + if (!other.canEqual(this)) return false; + if (!super.equals(o)) return false; if (this.width != other.width) return false; if (this.height != other.height) return false; return true; @@ -60,5 +66,9 @@ public class EqualsAndHashCodeExample { result = (result*PRIME) + this.height; return result; } + + public boolean canEqual(Object other) { + return other instanceof Square; + } } } |