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 /website/features/EqualsAndHashCode.html | |
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 'website/features/EqualsAndHashCode.html')
-rw-r--r-- | website/features/EqualsAndHashCode.html | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/website/features/EqualsAndHashCode.html b/website/features/EqualsAndHashCode.html index c5128d10..dbe45218 100644 --- a/website/features/EqualsAndHashCode.html +++ b/website/features/EqualsAndHashCode.html @@ -28,10 +28,16 @@ </p><p> Setting <code>callSuper</code> to <em>true</em> when you don't extend anything (you extend <code>java.lang.Object</code>) is a compile-time error, because it would turn the generated <code>equals()</code> and <code>hashCode()</code> implementations into having the same behaviour as simply inheriting these methods from <code>java.lang.Object</code>: - only the same object will be equal to each other and will have the same hashCode. Obviously, inheriting <code>java.lang.Object</code> is the right strategy if you want this behaviour. + only the same object will be equal to each other and will have the same hashCode. Not setting <code>callSuper</code> to <em>true</em> when you extend another class generates a warning, because unless the superclass has no (equality-important) fields, lombok cannot generate an implementation for you that takes into account the fields declared by your superclasses. You'll need to write your own implementations, or rely on the <code>callSuper</code> chaining facility. + </p><p> + <em>NEW in Lombok 0.10: </em>Unless your class is <code>final</code> and extends <code>java.lang.Object</code>, lombok generates a <code>canEqual</code> method + which means JPA proxies can still be equal to their base class, but subclasses that add new state don't break the equals contract. The complicated reasons for + why such a method is necessary are explained in this paper: (TODO: Find link to Venners/Spoon/Odersky). If all classes in a hierarchy are a mix of scala case classes + and classes with lombok-generated equals methods, all equality will 'just work'. If you need to write your own equals methods, you should always override <code>canEqual</code> + if you change <code>equals</code> and <code>hashCode</code>. </p> </div> <div class="snippets"> |