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.eclipse.virgo.ide.management.remote.ServiceReference.java

@Override
public boolean equals(Object other) {
    if (this == other) {
        return true;
    }//from w  w  w .j  a  v a  2s  .  co m
    if (!(other instanceof ServiceReference)) {
        return false;
    }
    ServiceReference that = (ServiceReference) other;
    if (!ObjectUtils.nullSafeEquals(this.clazzes, that.clazzes))
        return false;
    if (!ObjectUtils.nullSafeEquals(this.type, that.type))
        return false;
    return true;
}

From source file:org.wallride.service.CommentService.java

public Comment updateComment(CommentUpdateRequest request, AuthorizedUser updatedBy) {
    Comment comment = commentRepository.findOneForUpdateById(request.getId());
    if (comment == null) {
        throw new ServiceException();
    }/*from ww w .j  ava 2  s .  co  m*/
    if (!updatedBy.getRoles().contains(User.Role.ADMIN)
            || !ObjectUtils.nullSafeEquals(comment.getAuthor(), updatedBy)) {
        throw new ServiceException();
    }

    LocalDateTime now = LocalDateTime.now();
    comment.setContent(request.getContent());
    comment.setUpdatedAt(now);
    comment.setUpdatedBy(updatedBy.toString());
    return commentRepository.saveAndFlush(comment);
}

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

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*from   w  w  w  . j a  va 2 s.  c  o m*/
    if (!(obj instanceof General)) {
        return false;
    }
    General general = (General) obj;
    return ObjectUtils.nullSafeEquals(this.getJndiName(), general.getJndiName());
}

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

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*  w ww  .j av a  2 s.  c  o  m*/
    if (!(obj instanceof TomcatDataSource)) {
        return false;
    }
    TomcatDataSource dataSource = (TomcatDataSource) obj;
    return ObjectUtils.nullSafeEquals(this.getConnection(), dataSource.getConnection())
            && ObjectUtils.nullSafeEquals(this.getConnectionPool(), dataSource.getConnectionPool())
            && ObjectUtils.nullSafeEquals(this.getGeneral(), dataSource.getGeneral());
}

From source file:org.brekka.stillingar.spring.pc.PropertyDefChangeListener.java

/**
 * Update the property with the new value
 *//*w  w  w . j  a v  a  2 s  .  c o  m*/
@Override
public void onChange(String newValue) {
    ConfigurableListableBeanFactory beanFactory = beanFactoryRef.get();
    if (beanFactory == null) {
        return;
    }
    BeanDefinition beanDef = beanFactory.getMergedBeanDefinition(beanName);
    MutablePropertyValues mutablePropertyValues = beanDef.getPropertyValues();
    PropertyValue propertyValue = mutablePropertyValues.getPropertyValue(propertyName);
    if (!ObjectUtils.nullSafeEquals(newValue, propertyValue.getValue())) {
        mutablePropertyValues.add(propertyValue.getName(), newValue);
    }
}

From source file:org.brekka.stillingar.spring.pc.CustomBeanDefinitionVisitor.java

/**
 * Visit properties//from  ww w. j av  a 2  s.c om
 */
@Override
protected void visitPropertyValues(MutablePropertyValues pvs) {
    PropertyValue[] pvArray = pvs.getPropertyValues();
    for (PropertyValue pv : pvArray) {
        currentProperty = pv;
        Object newVal = resolveValue(pv.getValue());

        // Change the value for the first time.
        if (!ObjectUtils.nullSafeEquals(newVal, pv.getValue())) {
            pvs.add(pv.getName(), newVal);
        }
        currentProperty = null;
    }
}

From source file:org.springmodules.validation.bean.conf.CascadeValidation.java

public boolean equals(Object object) {
    if (this == object) {
        return true;
    }// www  .j a  va  2 s .  co  m

    if (object == null || getClass() != object.getClass()) {
        return false;
    }

    CascadeValidation that = (CascadeValidation) object;

    if (!propertyName.equals(that.propertyName)) {
        return false;
    }

    return (ObjectUtils.nullSafeEquals(applicabilityCondition, that.applicabilityCondition));
}

From source file:com.springsource.hq.plugin.tcserver.serverconfig.services.connector.AjpConnector.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*  w w w .j av a2 s.c o m*/
    if (!(obj instanceof AjpConnector)) {
        return false;
    }
    AjpConnector connector = (AjpConnector) obj;
    return ObjectUtils.nullSafeEquals(this.getProtocol(), connector.getProtocol())
            && ObjectUtils.nullSafeEquals(this.getRequestSecret(), connector.getRequestSecret())
            && ObjectUtils.nullSafeEquals(this.getRequestUseSecret(), connector.getRequestUseSecret())
            && ObjectUtils.nullSafeEquals(this.getAddress(), connector.getAddress())
            && ObjectUtils.nullSafeEquals(this.getConnectionTimeout(), connector.getConnectionTimeout())
            && ObjectUtils.nullSafeEquals(this.getConnectorName(), connector.getConnectorName())
            && ObjectUtils.nullSafeEquals(this.getMaxThreads(), connector.getMaxThreads())
            && ObjectUtils.nullSafeEquals(this.getPort(), connector.getPort())
            && ObjectUtils.nullSafeEquals(this.getProxyName(), connector.getProxyName())
            && ObjectUtils.nullSafeEquals(this.getProxyPort(), connector.getProxyPort())
            && ObjectUtils.nullSafeEquals(this.getRedirectPort(), connector.getRedirectPort())
            && ObjectUtils.nullSafeEquals(this.getScheme(), connector.getScheme());
}

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

@Override
public boolean equals(final Object obj) {
    if (obj == this) {
        return true;
    }//from   w  w w .  ja v a2s. c om

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

    User that = (User) obj;

    return this.getUsername().equals(that.getUsername())
            && ObjectUtils.nullSafeEquals(this.getEmail(), that.getEmail());
}