Example usage for org.apache.commons.lang3.builder EqualsBuilder isEquals

List of usage examples for org.apache.commons.lang3.builder EqualsBuilder isEquals

Introduction

In this page you can find the example usage for org.apache.commons.lang3.builder EqualsBuilder isEquals.

Prototype

boolean isEquals

To view the source code for org.apache.commons.lang3.builder EqualsBuilder isEquals.

Click Source Link

Document

If the fields tested are equals.

Usage

From source file:com.nmote.smpp.BindTransceiverPDU.java

/**
 * Checks if <code>o</code> and this object are equal.
 *
 * @return true if objects are equal, false otherwise
 *//*from  www .  j a  v a 2s . c o m*/
public boolean equals(Object o) {
    boolean result;
    if (o instanceof BindTransceiverPDU) {
        BindTransceiverPDU p = (BindTransceiverPDU) o;
        EqualsBuilder b = new EqualsBuilder();
        b.append(p.getSequence(), getSequence());
        b.append(p.getStatus(), getStatus());

        // Appending mandatory parameters
        b.append(p.system_id, system_id);
        b.append(p.password, password);
        b.append(p.system_type, system_type);
        b.append(p.interface_version, interface_version);
        b.append(p.address_range, address_range);

        // Appending optional parameters
        b.append(p.getParameters(), getParameters());

        result = b.isEquals();
    } else {
        result = false;
    }

    return result;
}

From source file:com.silverpeas.gallery.web.PhotoEntityMatcher.java

@Override
public boolean matches(final Object item) {
    boolean match = false;
    if (item instanceof PhotoEntity) {
        final PhotoEntity actual = (PhotoEntity) item;
        final EqualsBuilder matcher = new EqualsBuilder();
        matcher.appendSuper(actual.getURI().toString().endsWith("/gallery/componentName5/albums/3/photos/7"));
        matcher.appendSuper(actual.getParentURI().toString().endsWith("/gallery/componentName5/albums/3"));
        matcher.append("photo", actual.getType());
        matcher.append(expected.getId(), actual.getId());
        matcher.append(expected.getTitle(), actual.getTitle());
        matcher.append(expected.getDescription(), actual.getDescription());
        matcher.appendSuper(/*from  ww  w . j  a  v  a  2 s.c  om*/
                actual.getPreviewUrl().endsWith("/gallery/componentName5/albums/3/photos/7/previewContent"));
        matcher.appendSuper(actual.getUrl().endsWith("/gallery/componentName5/albums/3/photos/7/content"));
        match = matcher.isEquals();
    }
    return match;
}

From source file:de.perdian.apps.dashboard.mvc.modules.project.ProjectControllerRequest.java

@Override
public boolean equals(Object that) {
    if (that instanceof ProjectControllerRequest) {
        ProjectControllerRequest thatRequest = (ProjectControllerRequest) that;
        EqualsBuilder equalsBuilder = new EqualsBuilder();
        equalsBuilder.append(this.getJenkinsJobName(), thatRequest.getJenkinsJobName());
        equalsBuilder.append(this.getJenkinsPassword(), thatRequest.getJenkinsPassword());
        equalsBuilder.append(this.getJenkinsUrl(), thatRequest.getJenkinsUrl());
        equalsBuilder.append(this.getJenkinsUsername(), thatRequest.getJenkinsUsername());
        equalsBuilder.append(this.getSonarPassword(), thatRequest.getSonarPassword());
        equalsBuilder.append(this.getSonarProjectName(), thatRequest.getSonarProjectName());
        equalsBuilder.append(this.getSonarUrl(), thatRequest.getSonarUrl());
        equalsBuilder.append(this.getSonarUsername(), thatRequest.getSonarUsername());
        return equalsBuilder.isEquals();
    } else {/*from  w  w  w  . j a va  2 s.  c  o  m*/
        return false;
    }
}

From source file:com.nmote.smpp.DataSmPDU.java

/**
 * Checks if <code>o</code> and this object are equal.
 *
 * @return true if objects are equal, false otherwise
 *//*  w  w w .ja  va2 s.c  o  m*/
public boolean equals(Object o) {
    boolean result;
    if (o instanceof DataSmPDU) {
        DataSmPDU p = (DataSmPDU) o;
        EqualsBuilder b = new EqualsBuilder();
        b.append(p.getSequence(), getSequence());
        b.append(p.getStatus(), getStatus());

        // Appending mandatory parameters
        b.append(p.service_type, service_type);
        b.append(p.source_addr, source_addr);
        b.append(p.dest_addr, dest_addr);
        b.append(p.esm_class, esm_class);
        b.append(p.registered_delivery, registered_delivery);
        b.append(p.data_coding, data_coding);

        // Appending optional parameters
        b.append(p.getParameters(), getParameters());

        result = b.isEquals();
    } else {
        result = false;
    }

    return result;
}

From source file:com.silverpeas.gallery.web.AlbumEntityMatcher.java

@SuppressWarnings("unchecked")
@Override//from ww  w  . jav a2s .com
public boolean matches(final Object item) {
    boolean match = false;
    if (item instanceof LinkedHashMap) {
        final AlbumEntity actual = from((LinkedHashMap<String, Object>) item);
        final EqualsBuilder matcher = new EqualsBuilder();
        matcher.appendSuper(actual.getURI().toString().endsWith("/gallery/componentName5/albums/3"));
        matcher.appendSuper(actual.getParentURI().toString().endsWith("/gallery/componentName5/albums/0"));
        matcher.append(String.valueOf(expected.getId()), actual.getId());
        matcher.append(expected.getName(), actual.getTitle());
        matcher.append(expected.getDescription(), actual.getDescription());
        matcher.append(4, actual.getMediaList().size());
        Set<String> keySet = actual.getMediaList().keySet();
        matcher.appendSuper(keySet.contains(PHOTO_ID));
        matcher.appendSuper(keySet.contains(VIDEO_ID));
        matcher.appendSuper(keySet.contains(SOUND_ID));
        matcher.appendSuper(keySet.contains(STREAMING_ID));
        match = matcher.isEquals();
    }
    return match;
}

From source file:com.jdom.get.stuff.done.domain.Task.java

public boolean equals(com.google.api.services.tasks.model.Task googleTask, String listName) {
    EqualsBuilder eqBuilder = new EqualsBuilder();
    eqBuilder.append(this.isDeleted(), Boolean.parseBoolean("" + googleTask.getDeleted()));
    eqBuilder.append(this.isCompleted(), "completed".equals(googleTask.getStatus()));
    eqBuilder.append(this.getName(), googleTask.getTitle());
    eqBuilder.append(this.getListName(), listName);

    Date thisDueDate = DateUtil.getDateZeroingHoursAndBelow(getDueDate());
    long raw = 0;
    DateTime googleDue = googleTask.getDue();
    if (googleDue != null) {
        raw = googleDue.getValue();/* w  w  w.ja  v a2s  .c om*/
        raw -= TimeZone.getDefault().getOffset(raw);
    }
    Date thatDueDate = DateUtil.getDateZeroingHoursAndBelow(new Date(raw));

    eqBuilder.append(thisDueDate, thatDueDate);
    return eqBuilder.isEquals();
}

From source file:com.nmote.smpp.ReplaceSmPDU.java

/**
 * Checks if <code>o</code> and this object are equal.
 *
 * @return true if objects are equal, false otherwise
 *///from   w  ww .  j  a  va2s  .c  om
public boolean equals(Object o) {
    boolean result;
    if (o instanceof ReplaceSmPDU) {
        ReplaceSmPDU p = (ReplaceSmPDU) o;
        EqualsBuilder b = new EqualsBuilder();
        b.append(p.getSequence(), getSequence());
        b.append(p.getStatus(), getStatus());

        // Appending mandatory parameters
        b.append(p.message_id, message_id);
        b.append(p.source_addr, source_addr);
        b.append(p.schedule_delivery_time, schedule_delivery_time);
        b.append(p.validity_period, validity_period);
        b.append(p.registered_delivery, registered_delivery);
        b.append(p.sm_default_msg_id, sm_default_msg_id);
        b.append(p.short_message, short_message);

        // Appending optional parameters
        b.append(p.getParameters(), getParameters());

        result = b.isEquals();
    } else {
        result = false;
    }

    return result;
}

From source file:com.francetelecom.clara.cloud.logicalmodel.LogicalService.java

/**
 * Utility method to factor out logic between {@link #equals(Object)} and {@link #equalsShallow(LogicalService)}
 * @param obj The other object to compare
 * @param excludeAssociations set to true to exclude the {@link #logicalNodeServiceAssociations} in the comparison
 *                            or false to include them.
 * @return/*  www  . j a v  a 2s. com*/
 */
protected boolean equals(Object obj, boolean excludeAssociations) {
    if (obj == null) {
        return false;
    }
    if (obj == this) {
        return true;
    }
    if (obj.getClass() != getClass()) {
        return false;
    }
    LogicalService rhs = (LogicalService) obj;

    EqualsBuilder equalsBuilder = new EqualsBuilder().appendSuper(super.equals(obj, EqualsUtils
            .mergeExcludedFieldLists(EXCLUDED_EQUALS_FIELDS, EXCLUDED_HIBERNATE_BROKEN_EQUALS_COLLECTIONS)));

    if (!excludeAssociations) {
        List<LogicalNodeServiceAssociation> thisLogicalNodeServiceAssociations = new ArrayList<LogicalNodeServiceAssociation>(
                logicalNodeServiceAssociations);
        Collections.sort(thisLogicalNodeServiceAssociations);
        List<LogicalNodeServiceAssociation> rhsLogicalNodeServiceAssociations = new ArrayList<LogicalNodeServiceAssociation>(
                rhs.logicalNodeServiceAssociations);
        Collections.sort(rhsLogicalNodeServiceAssociations);
        equalsBuilder.append(thisLogicalNodeServiceAssociations, rhsLogicalNodeServiceAssociations);
    }

    return equalsBuilder.isEquals();
}

From source file:com.nmote.smpp.BroadcastSmPDU.java

/**
 * Checks if <code>o</code> and this object are equal.
 *
 * @return true if objects are equal, false otherwise
 *//*ww w . j a  v  a 2  s.com*/
public boolean equals(Object o) {
    boolean result;
    if (o instanceof BroadcastSmPDU) {
        BroadcastSmPDU p = (BroadcastSmPDU) o;
        EqualsBuilder b = new EqualsBuilder();
        b.append(p.getSequence(), getSequence());
        b.append(p.getStatus(), getStatus());

        // Appending mandatory parameters
        b.append(p.service_type, service_type);
        b.append(p.source_addr, source_addr);
        b.append(p.message_id, message_id);
        b.append(p.priority_flag, priority_flag);
        b.append(p.schedule_delivery_time, schedule_delivery_time);
        b.append(p.validity_period, validity_period);
        b.append(p.replace_if_present_flag, replace_if_present_flag);
        b.append(p.data_coding, data_coding);
        b.append(p.sm_default_msg_id, sm_default_msg_id);

        // Appending optional parameters
        b.append(p.getParameters(), getParameters());

        result = b.isEquals();
    } else {
        result = false;
    }

    return result;
}

From source file:annis.model.DataObject.java

@Override
public boolean equals(final Object obj) {
    // enforce equals contract (turn on debugging for this class to see the bug)
    if (obj == null)
        return false;

    if (this.getClass() != obj.getClass())
        return false;

    final EqualsBuilder equalsBuilder = new EqualsBuilder();

    final Object _this = this;
    forEachFieldDo(new FieldCallBack() {

        public void doForField(Field field) throws IllegalAccessException {
            Object thisValue = field.get(_this);
            Object otherValue = field.get(obj);
            if (log.isDebugEnabled()) {
                String fieldName = field.getDeclaringClass().getSimpleName() + "." + field.getName();
                try {
                    boolean equal = thisValue != null && thisValue.equals(otherValue)
                            || thisValue == null && otherValue == null;
                    log.debug(fieldName + ": " + thisValue + " " + (equal ? "=" : "!=") + " " + otherValue);
                } catch (RuntimeException e) {
                    log.error("Exception while comparing " + fieldName + "(" + thisValue + ", " + otherValue
                            + ")");
                    throw e;
                }//  w w  w .jav  a  2 s  . c  om
            }
            equalsBuilder.append(thisValue, otherValue);
        }

    });

    return equalsBuilder.isEquals();

}