Example usage for org.apache.commons.beanutils DynaClass equals

List of usage examples for org.apache.commons.beanutils DynaClass equals

Introduction

In this page you can find the example usage for org.apache.commons.beanutils DynaClass equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.apache.ddlutils.dynabean.SqlDynaBean.java

/**
 * {@inheritDoc}/*  w  w  w .  ja va 2 s.c  o m*/
 */
public boolean equals(Object obj) {
    if (obj instanceof SqlDynaBean) {
        SqlDynaBean other = (SqlDynaBean) obj;
        DynaClass dynaClass = getDynaClass();

        if (dynaClass.equals(other.getDynaClass())) {
            DynaProperty[] props = dynaClass.getDynaProperties();

            for (int idx = 0; idx < props.length; idx++) {
                Object value = get(props[idx].getName());
                Object otherValue = other.get(props[idx].getName());

                if (value == null) {
                    if (otherValue != null) {
                        return false;
                    }
                } else {
                    return value.equals(otherValue);
                }
            }
            return true;
        }
    }
    return false;
}