com.ibm.j2ca.base
Class BeanUtil

java.lang.Object
  extended bycom.ibm.j2ca.base.BeanUtil

public class BeanUtil
extends java.lang.Object

Collection of methods for comparing, copying and generally evaluating Java beans and their property values. This class is intended for use in providing dynamic implementations of methods like equals, hashCode, etc. in the base implementations.


Constructor Summary
BeanUtil()
           
 
Method Summary
static void copyAllValues(java.lang.Object srcBean, java.lang.Object dstBean)
          Copies the property values of one JavaBean to the same properties of another; properties that are not shared between the two beans are ignored.
static int hashCode(java.lang.Object bean)
          Calculates a hashcode for a JavaBean using values of exposed properties.
static int hashCode(java.lang.Object bean, java.lang.String[] excludedPropertyNames)
          Calculates a hashcode for a JavaBean using values of exposed properties.
static boolean haveEqualProperties(java.lang.Object bean1, java.lang.Object bean2)
          Compares values of two JavaBeans.
static boolean haveEqualProperties(java.lang.Object bean1, java.lang.Object bean2, java.lang.String[] excludedPropertyNames)
          Compares values of two JavaBeans.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanUtil

public BeanUtil()
Method Detail

haveEqualProperties

public static boolean haveEqualProperties(java.lang.Object bean1,
                                          java.lang.Object bean2,
                                          java.lang.String[] excludedPropertyNames)
                                   throws BeanUtilException
Compares values of two JavaBeans.

Returns:
true if beans expose the same properties and have the same values
Throws:
BeanUtilException

haveEqualProperties

public static boolean haveEqualProperties(java.lang.Object bean1,
                                          java.lang.Object bean2)
                                   throws BeanUtilException
Compares values of two JavaBeans.

Returns:
true if beans expose the same properties and have the same values
Throws:
BeanUtilException

copyAllValues

public static void copyAllValues(java.lang.Object srcBean,
                                 java.lang.Object dstBean)
                          throws BeanUtilException
Copies the property values of one JavaBean to the same properties of another; properties that are not shared between the two beans are ignored.

Throws:
BeanUtilException

hashCode

public static int hashCode(java.lang.Object bean)
                    throws BeanUtilException
Calculates a hashcode for a JavaBean using values of exposed properties.

Throws:
BeanUtilException

hashCode

public static int hashCode(java.lang.Object bean,
                           java.lang.String[] excludedPropertyNames)
                    throws BeanUtilException
Calculates a hashcode for a JavaBean using values of exposed properties.

Throws:
BeanUtilException