public abstract class RichObject extends Object
equals(Object)
, hashCode()
and toString()
for its subtypes.
These implementations are based on annotating the fields of the subtypes with the Identity
annotation.
Constructor and Description |
---|
RichObject() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Implementation of equals based on fields annotated with
Identity . |
int |
hashCode()
Default implementation of hashCode - can be overridden to provide more efficient ones provided the contract specified
in
Object.hashCode() is maintained with respect to equals(Object) . |
String |
toString()
Default implementation of toString.
|
public final boolean equals(Object other)
Identity
.
Applies equality rules on the following basis (in addition to the rules in Object.equals(Object)
):
Identity
as those on the runtime
class of this instance, where the set of fields in each case comprises those on the class and all of its superclasses
Identity
on this must be equal to the value of the same field on other
The practical result of this is that an instance of subtype B of subtype A of RichObject can only be equal to an instance
of subtype A if B does not annotate any of its fields with Identity
.
public int hashCode()
Object.hashCode()
is maintained with respect to equals(Object)
.Copyright © 2006-2013. All Rights Reserved.