Example usage for org.springframework.util ObjectUtils nullSafeEquals

List of usage examples for org.springframework.util ObjectUtils nullSafeEquals

Introduction

In this page you can find the example usage for org.springframework.util ObjectUtils nullSafeEquals.

Prototype

public static boolean nullSafeEquals(@Nullable Object o1, @Nullable Object o2) 

Source Link

Document

Determine if the given objects are equal, returning true if both are null or false if only one is null .

Usage

From source file:org.springmodules.jcr.config.JcrNamespaceHandlerTests.java

public void testEventListenerDefinition() throws Exception {
    RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory
            .getBeanDefinition("eventListenerFull");
    assertSame(EventListenerDefinition.class, beanDefinition.getBeanClass());
    assertPropertyValue(beanDefinition, "absPath", "/somePath");
    assertPropertyValue(beanDefinition, "isDeep", "true");
    assertPropertyValue(beanDefinition, "noLocal", "false");
    assertPropertyValue(beanDefinition, "eventType", new Integer(17));
    assertTrue(ObjectUtils.nullSafeEquals(new String[] { "123" },
            (Object[]) getPropertyValue(beanDefinition, "uuid")));
    assertTrue(ObjectUtils.nullSafeEquals(new String[] { "foo", "bar" },
            (Object[]) getPropertyValue(beanDefinition, "nodeTypeName")));
}

From source file:com.springsource.hq.plugin.tcserver.serverconfig.resources.jdbc.General.java

public void validate(Object target, Errors errors) {
    General general = (General) target;//from   w  w  w .  j  ava  2 s  .  c om
    if (!errors.hasFieldErrors("jndiName")) {
        if (!StringUtils.hasText(general.getJndiName())) {
            errors.rejectValue("jndiName", "resource.dataSource.general.jndiName.required");
        } else {
            if (general.parent() != null) {
                // detect duplicate jndi names
                for (DataSource dataSource : general.parent().parent().getDataSources()) {
                    General g = dataSource.getGeneral();
                    if (g != general && ObjectUtils.nullSafeEquals(general.getJndiName(), g.getJndiName())) {
                        errors.reject("resource.dataSource.general.jndiName.unique",
                                new Object[] { general.getJndiName() }, null);
                    }
                }
            }
        }
    }
}

From source file:ei.ne.ke.cassandra.cql3.template.Relation.java

/**
 * {@inheritDoc}/*from ww w.  ja  va  2 s. c o m*/
 */
@Override
public boolean equals(Object rhs) {
    if (this == rhs) {
        return true;
    } else if (!(rhs instanceof Relation)) {
        return false;
    } else {
        Relation that = (Relation) rhs;
        return ObjectUtils.nullSafeEquals(this.identifier, that.identifier)
                && ObjectUtils.nullSafeEquals(this.comparator, that.comparator)
                && ObjectUtils.nullSafeEquals(this.term, that.term);
    }
}

From source file:cat.albirar.framework.sets.registry.impl.NamedSetDefaultImpl.java

/**
 * Add the {@link #getName()} on equals algorithm.
 * /*  ww  w.  ja v  a 2  s . c o  m*/
 * {@inheritDoc}
 */
@Override
public boolean equals(Object o) {
    if (o == this) {
        return true;
    }
    if (o == null) {
        return false;
    }

    if (INamedSet.class.isAssignableFrom(o.getClass())) {
        return (ObjectUtils.nullSafeEquals(name, ((INamedSet<?>) o).getName()) && super.equals(o));
    }
    return false;
}

From source file:com.frank.search.solr.core.schema.SchemaDefinition.java

public FieldDefinition getFieldDefinition(String name) {

    if (CollectionUtils.isEmpty(this.fields)) {
        return null;
    }//from ww w .  j  av a  2 s  .  com

    for (FieldDefinition fd : this.fields) {
        if (ObjectUtils.nullSafeEquals(fd.getName(), name)) {
            return fd;
        }
    }

    return null;
}

From source file:lodsve.core.condition.ConditionOutcome.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*from w w  w  .j  a  va2s .  c o  m*/
    if (obj == null) {
        return false;
    }
    if (getClass() == obj.getClass()) {
        ConditionOutcome other = (ConditionOutcome) obj;
        return (this.match == other.match && ObjectUtils.nullSafeEquals(this.message, other.message));
    }
    return super.equals(obj);
}

From source file:com.springsource.hq.plugin.tcserver.serverconfig.configuration.context.WebApplicationLogger.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }//from ww w  .  j ava 2 s  . co m
    if (!(obj instanceof WebApplicationLogger)) {
        return false;
    }
    WebApplicationLogger webApplicationLogger = (WebApplicationLogger) obj;
    return ObjectUtils.nullSafeEquals(this.getSwallowOutput(), webApplicationLogger.getSwallowOutput());
}

From source file:com.px100systems.data.core.RawRecord.java

@Override
public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof RawRecord))
        return false;

    RawRecord o = (RawRecord) obj;//from www  . j  a v a  2  s.  c  o m

    String data1 = serializedEntity == null ? "" : serializedEntity;
    String data2 = o.serializedEntity == null ? "" : o.serializedEntity;
    if (!data1.equals(data2))
        return false;

    return ObjectUtils.nullSafeEquals(unitName, o.unitName) && ObjectUtils.nullSafeEquals(id, o.id)
            && ObjectUtils.nullSafeEquals(lastUpdate, o.lastUpdate);
}

From source file:org.spring.data.gemfire.app.beans.PhoneNumber.java

@Override
public boolean equals(final Object obj) {
    if (obj == this) {
        return true;
    }/* ww  w .ja  v a  2  s  .  c o  m*/

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

    PhoneNumber that = (PhoneNumber) obj;

    return ObjectUtils.nullSafeEquals(this.getAreaCode(), that.getAreaCode())
            && ObjectUtils.nullSafeEquals(this.getPrefix(), that.getPrefix())
            && ObjectUtils.nullSafeEquals(this.getSuffix(), that.getSuffix())
            && ObjectUtils.nullSafeEquals(this.getExtension(), that.getExtension());
}

From source file:org.devefx.httpmapper.http.HttpEntity.java

@Override
public boolean equals(Object other) {
    if (this == other) {
        return true;
    }/*from ww w  .  j  av a  2 s.  c  om*/
    if (other == null || other.getClass() != getClass()) {
        return false;
    }
    HttpEntity<?> otherEntity = (HttpEntity<?>) other;
    return (ObjectUtils.nullSafeEquals(this.headers, otherEntity.headers)
            && ObjectUtils.nullSafeEquals(this.body, otherEntity.body));
}