Example usage for org.apache.commons.lang.builder CompareToBuilder append

List of usage examples for org.apache.commons.lang.builder CompareToBuilder append

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder CompareToBuilder append.

Prototype

public CompareToBuilder append(Object[] lhs, Object[] rhs, Comparator comparator) 

Source Link

Document

Appends to the builder the deep comparison of two Object arrays.

  1. Check if arrays are the same using ==
  2. Check if for null, null is less than non-null
  3. Check array length, a short length array is less than a long length array
  4. Check array contents element by element using #append(Object,Object,Comparator)

This method will also will be called for the top level of multi-dimensional, ragged, and multi-typed arrays.

Usage

From source file:org.drools.planner.core.localsearch.decider.forager.AcceptedMoveScopeComparator.java

public int compare(MoveScope a, MoveScope b) {
    CompareToBuilder compareToBuilder = new CompareToBuilder();
    compareToBuilder.append(a.getScore(), b.getScore(), deciderScoreComparator);
    // moves are not compared
    return compareToBuilder.toComparison();
}

From source file:org.kuali.kra.common.notification.lookup.keyvalue.KeyLabelSortByValue.java

@Override
public int compareTo(KeyLabelPair o) {
    if (o == null) {
        throw new NullPointerException("the object to compare to is null");
    }//from w  ww  . ja va 2  s.co m
    CompareToBuilder builder = new CompareToBuilder();
    builder.append(this.label, o.label, String.CASE_INSENSITIVE_ORDER);

    if ((this.key instanceof String) && (o.key instanceof String))
        builder.append(this.key, o.key, String.CASE_INSENSITIVE_ORDER);
    else {
        builder.append(this.key, o.key);
    }

    builder.append(this.numPaddedSpaces, o.numPaddedSpaces);
    return builder.toComparison();

}