org.joe_e
Class Struct
java.lang.Object
org.joe_e.Struct
- All Implemented Interfaces:
- Selfless
public abstract class Struct
- extends Object
- implements Selfless
This abstract class contains implementations of the equals() and hashCode()
methods that satisfy the Selfless interface. The provided equals() method
computes equality of all fields using reflection.
Constructor Summary |
protected |
Struct()
|
Method Summary |
boolean |
equals(Object other)
Tests for equality with another object. |
int |
hashCode()
Calculates the hash code. |
Struct
protected Struct()
equals
public final boolean equals(Object other)
- Tests for equality with another object. An obect is equal to this one
if it is of identical type and each field is equal for the two objects.
The objects' fields are equal if both are null, or if their values
return true for
equals()
. This implementation uses
reflection to work for any subclass of Struct
.
- Overrides:
equals
in class Object
- Parameters:
other
- candidate object
- Returns:
- true if it is equal to this object
- See Also:
Object.hashCode()
,
HashMap
hashCode
public final int hashCode()
- Calculates the hash code.
This method will satisfy the contract of the hashCode method for any
subclass of
Struct
. (two structs that are
equal()
structs will always have the same hashCode). The
precise return value of this method is unspecified, and may change in
future releases.
- Specified by:
hashCode
in interface Selfless
- Overrides:
hashCode
in class Object
- Returns:
- a hash value
- See Also:
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)