com.sun.syndication.feed.impl
Class EqualsBean

java.lang.Object
  extended by com.sun.syndication.feed.impl.EqualsBean
All Implemented Interfaces:
Serializable

public class EqualsBean
extends Object
implements Serializable

Provides deep Bean equals() and hashCode() functionality for Java Beans.

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.

Author:
Alejandro Abdelnur
See Also:
Serialized Form

Constructor Summary
protected EqualsBean(Class<?> beanClass)
          Default constructor.
  EqualsBean(Class<?> beanClass, Object obj)
          Creates a EqualsBean to be used in a delegation pattern.
 
Method Summary
 boolean beanEquals(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.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this object as defined by the Object equals() method.
 int hashCode()
          Returns the hashcode for this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EqualsBean

protected EqualsBean(Class<?> beanClass)
Default constructor.

To be used by classes extending EqualsBean only.

Parameters:
beanClass - the class/interface to be used for property scanning.

EqualsBean

public EqualsBean(Class<?> beanClass,
                  Object obj)
Creates a EqualsBean to be used in a delegation pattern.

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(); } }

Parameters:
beanClass - the class/interface to be used for property scanning.
obj - object bean to test equality.
Method Detail

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this object as defined by the Object equals() method.

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

Overrides:
equals in class Object
Parameters:
obj - he reference object with which to compare.
Returns:
true if 'this' object is equal to the 'other' object.
See Also:
beanEquals method.


beanEquals

public boolean beanEquals(Object obj)
Indicates whether some other object is "equal to" the object passed in the constructor, as defined by the Object equals() method.

To be used by classes using EqualsBean in a delegation pattern,

Parameters:
obj - he reference object with which to compare.
Returns:
true if the object passed in the constructor is equal to the 'obj' object.
See Also:
constructor.


hashCode

public int hashCode()
Returns the hashcode for this object.

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

Overrides:
hashCode in class Object
Returns:
the hashcode of the bean object.
See Also:
beanHashCode method.


beanHashCode

public int beanHashCode()
Returns the hashcode for the object passed in the constructor.

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,

Returns:
the hashcode of the bean object.
See Also:
constructor.



Copyright © 2004–2013 ROME Project. All rights reserved.