Example usage for org.apache.commons.lang ObjectUtils equals

List of usage examples for org.apache.commons.lang ObjectUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang ObjectUtils equals.

Prototype

public static boolean equals(Object object1, Object object2) 

Source Link

Document

Compares two objects for equality, where either one or both objects may be null.

 ObjectUtils.equals(null, null)                  = true ObjectUtils.equals(null, "")                    = false ObjectUtils.equals("", null)                    = false ObjectUtils.equals("", "")                      = true ObjectUtils.equals(Boolean.TRUE, null)          = false ObjectUtils.equals(Boolean.TRUE, "true")        = false ObjectUtils.equals(Boolean.TRUE, Boolean.TRUE)  = true ObjectUtils.equals(Boolean.TRUE, Boolean.FALSE) = false 

Usage

From source file:com.healthmarketscience.jackcess.RowFilter.java

/**
 * Creates a filter based on a row pattern.
 * //from   w  ww . j a  v a  2  s.co  m
 * @param rowPattern Map from column names to the values to be matched.
 *                   A table row will match the target if
 *                   {@code ObjectUtils.equals(rowPattern.get(s), row.get(s))}
 *                   for all column names in the pattern map.
 * @return a filter which matches table rows which match the values in the
 *         row pattern
 */
public static RowFilter matchPattern(final Map<String, Object> rowPattern) {
    return new RowFilter() {
        @Override
        public boolean matches(Map<String, Object> row) {
            for (Map.Entry<String, Object> e : rowPattern.entrySet()) {
                if (!ObjectUtils.equals(e.getValue(), row.get(e.getKey()))) {
                    return false;
                }
            }
            return true;
        }
    };
}

From source file:com.opengamma.core.marketdatasnapshot.CurveKey.java

/**
 * Checks if this key equals another.//www.java  2s. com
 * <p>
 * This checks the currency and name.
 *
 * @param object  the object to compare to, null returns false
 * @return true if equal
 */
@Override
public boolean equals(Object object) {
    if (object == this) {
        return true;
    }
    if (object instanceof CurveKey) {
        CurveKey other = (CurveKey) object;
        return ObjectUtils.equals(getName(), other.getName());
    }
    return false;
}

From source file:gov.nih.nci.cabig.caaers.validation.annotation.UniqueIdentifierForStudyValidator.java

public boolean validate(Object value) {
    if (!(value instanceof Identifier))
        return true;
    Identifier id = (Identifier) value;// ww w .  java  2 s  .  c o  m
    StudyQuery query = new StudyQuery();
    query.filterByIdentifierValueExactMatch(id.getValue());
    query.filterByIdentifierType(id.getType());

    List<Study> studies = studyDao.find(query);
    for (Study study : studies) {
        for (Identifier otherId : study.getIdentifiersLazy()) {
            if (otherId.getValue().equals(id.getValue()) && otherId.getType().equals(id.getType())
                    && !ObjectUtils.equals(id.getId(), otherId.getId())) {

                if (id instanceof OrganizationAssignedIdentifier
                        && otherId instanceof OrganizationAssignedIdentifier) {
                    OrganizationAssignedIdentifier orgId = (OrganizationAssignedIdentifier) id;
                    OrganizationAssignedIdentifier orgOtherId = (OrganizationAssignedIdentifier) otherId;

                    boolean a1 = orgId.getId() == null;
                    boolean a2 = otherId.getId() == null;
                    if (!a1 && !a2 && orgId.getId().equals(orgOtherId.getId()))
                        return false;
                } else if (id instanceof SystemAssignedIdentifier
                        && otherId instanceof SystemAssignedIdentifier) {
                    SystemAssignedIdentifier sId = (SystemAssignedIdentifier) id;
                    SystemAssignedIdentifier sOtherId = (SystemAssignedIdentifier) otherId;
                    if (sId.getSystemName().equals(sOtherId.getSystemName()))
                        return false;
                }
            }
        }
    }
    return true;
}

From source file:de.schildbach.game.chess.ChessMove.java

@Override
public boolean equals(Object o) {
    ChessMove other = (ChessMove) o;/*from w  w  w.  ja v a  2  s.  c  o  m*/
    if (!super.equals(other))
        return false;
    if (!ObjectUtils.equals(this.promotionPiece, other.promotionPiece))
        return false;
    return true;
}

From source file:ca.sqlpower.wabit.report.selectors.AbstractSelector.java

public void setDefaultValue(Object defaultValue) {

    Object oldValue = this.defaultValue;
    this.defaultValue = defaultValue;

    if (!ObjectUtils.equals(oldValue, this.defaultValue)) {

        firePropertyChange("defaultValue", oldValue, this.defaultValue);

        if (ObjectUtils.equals(getCurrentValue(), oldValue)) {
            setSelectedValue(this.defaultValue);
        }/*www .  ja  va2s.com*/

        this.fireSelectionChanged();
    }
}

From source file:com.haulmont.cuba.gui.components.validators.IntegerValidator.java

private boolean checkIntegerOnPositive(Integer value) {
    return !ObjectUtils.equals("true", onlyPositive) || value >= 0;
}

From source file:be.fedict.eid.pkira.portal.framework.DataProviderBase.java

@Override
public T getItemByKey(Object key) {
    Integer theKey = (Integer) key;
    if (theKey == null)
        return null;

    if (data != null) {
        for (T item : data) {
            if (ObjectUtils.equals(getKey(item), theKey))
                return item;
        }/*  w ww .j a v a2s  .co m*/
    }

    return fetchItem((Integer) key);
}

From source file:com.qrmedia.commons.persistence.hibernate.clone.NonSimplePropertyEqualStubHibernateEntity.java

@Override
public boolean equals(Object obj) {

    if (this == obj) {
        return true;
    }//w w w .j a v  a 2 s.c  o m

    if (!(obj instanceof NonSimplePropertyEqualStubHibernateEntity)) {
        return false;
    }

    return ObjectUtils.equals(nonSimpleBeanProperty,
            ((NonSimplePropertyEqualStubHibernateEntity) obj).nonSimpleBeanProperty);
}

From source file:com.vmware.identity.idm.SecurityDomain.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }//from  w  w  w. ja  va2  s.co m
    if (obj == null || this.getClass() != obj.getClass()) {
        return false;
    }

    SecurityDomain other = (SecurityDomain) obj;

    return ObjectUtils.equals(_name, other._name) && ObjectUtils.equals(_alias, other._alias);
}

From source file:com.opengamma.core.historicaltimeseries.impl.HistoricalTimeSeriesKey.java

@Override
public boolean equals(Object object) {
    if (object == this) {
        return true;
    }/*from   w  w  w .  j a  v a  2 s.c  o  m*/
    if ((object instanceof HistoricalTimeSeriesKey)) {
        HistoricalTimeSeriesKey other = (HistoricalTimeSeriesKey) object;
        return ObjectUtils.equals(_externalIdBundle, other._externalIdBundle)
                && ObjectUtils.equals(_currentDate, other._currentDate)
                && ObjectUtils.equals(_dataProvider, other._dataProvider)
                && ObjectUtils.equals(_dataSource, other._dataSource)
                && ObjectUtils.equals(_dataField, other._dataField)
                && ObjectUtils.equals(_configName, other._configName);
    }
    return false;
}