public class EqualsBean
extends java.lang.Object
implements java.io.Serializable
It works on all read/write properties, recursively. It support all primitive types, Strings, Collections, bean-like objects and multi-dimensional arrays of any of them.
The hashcode is calculated by getting the hashcode of the Bean String representation.
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<?> |
beanClass |
private static java.lang.Object[] |
NO_PARAMS |
private java.lang.Object |
obj |
private static long |
serialVersionUID |
Modifier | Constructor and Description |
---|---|
protected |
EqualsBean(java.lang.Class<?> beanClass)
Default constructor.
|
|
EqualsBean(java.lang.Class<?> beanClass,
java.lang.Object obj)
Creates a EqualsBean to be used in a delegation pattern.
|
Modifier and Type | Method and Description |
---|---|
boolean |
beanEquals(java.lang.Object obj)
Indicates whether some other object is "equal to" the object passed in the constructor, as
defined by the Object equals() method.
|
int |
beanHashCode()
Returns the hashcode for the object passed in the constructor.
|
private boolean |
doEquals(java.lang.Object obj1,
java.lang.Object obj2) |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this object as defined by the Object
equals() method.
|
private boolean |
equalsArray(java.lang.Object array1,
java.lang.Object array2) |
int |
hashCode()
Returns the hashcode for this object.
|
private static final long serialVersionUID
private static final java.lang.Object[] NO_PARAMS
private final java.lang.Class<?> beanClass
private final java.lang.Object obj
protected EqualsBean(java.lang.Class<?> beanClass)
To be used by classes extending EqualsBean only.
beanClass
- the class/interface to be used for property scanning.public EqualsBean(java.lang.Class<?> beanClass, java.lang.Object obj)
For example:
public class Foo implements FooI {
private EqualsBean equalsBean;
public Foo() {
equalsBean = new EqualsBean(FooI.class);
}
public boolean equals(Object obj) {
return equalsBean.beanEquals(obj);
}
public int hashCode() {
return equalsBean.beanHashCode();
}
}
beanClass
- the class/interface to be used for property scanning.obj
- object bean to test equality.public boolean equals(java.lang.Object obj)
To be used by classes extending EqualsBean. Although it works also for classes using EqualsBean in a delegation pattern, for correctness those classes should use the
equals
in class java.lang.Object
obj
- he reference object with which to compare.beanEquals method.
public boolean beanEquals(java.lang.Object obj)
To be used by classes using EqualsBean in a delegation pattern,
obj
- he reference object with which to compare.constructor.
public int hashCode()
It follows the contract defined by the Object hashCode() method.
The hashcode is calculated by getting the hashcode of the Bean String representation.
To be used by classes extending EqualsBean. Although it works also for classes using EqualsBean in a delegation pattern, for correctness those classes should use the
hashCode
in class java.lang.Object
beanHashCode method.
public int beanHashCode()
It follows the contract defined by the Object hashCode() method.
The hashcode is calculated by getting the hashcode of the Bean String representation.
To be used by classes using EqualsBean in a delegation pattern,
constructor.
private boolean doEquals(java.lang.Object obj1, java.lang.Object obj2)
private boolean equalsArray(java.lang.Object array1, java.lang.Object array2)