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(boolean[] lhs, boolean[] rhs) 

Source Link

Document

Appends to the builder the deep comparison of two boolean 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 shorter length array is less than a longer length array
  4. Check array contents element by element using #append(boolean,boolean)

Usage

From source file:com.xtructure.xutil.ValueMap.java

@SuppressWarnings("unchecked")
@Override/* ww w. j a  va2 s .  c o m*/
public int compareTo(ValueMap that) {
    if (that == null) {
        return Integer.MAX_VALUE;
    }
    if (this.keySet().equals(that.keySet())) {
        CompareToBuilder ctb = new CompareToBuilder();
        List<XValId<?>> ids = new ArrayList<XValId<?>>(this.keySet());
        Collections.sort(ids);
        for (@SuppressWarnings("rawtypes")
        XValId id : ids) {
            ctb.append(this.get(id), that.get(id));
        }
        return ctb.toComparison();
    } else {
        List<XValId<?>> thisIds = new ArrayList<XValId<?>>(this.keySet());
        List<XValId<?>> thatIds = new ArrayList<XValId<?>>(that.keySet());
        Collections.sort(thisIds);
        Collections.sort(thatIds);
        return new CompareToBuilder()//
                .append(thisIds.toArray(new XValId<?>[0]), thatIds.toArray(new XValId<?>[0]))//
                .toComparison();
    }
}

From source file:net.sf.sze.model.zeugnis.Zeugnis.java

@Override
public int compareTo(final Zeugnis other) {
    final CompareToBuilder compareBuilder = new CompareToBuilder();
    compareBuilder.append(this.getSchulhalbjahr(), other.getSchulhalbjahr());
    compareBuilder.append(this.getKlasse(), other.getKlasse());
    compareBuilder.append(this.getSchueler(), other.getSchueler());
    return compareBuilder.toComparison();
}

From source file:org.acmsl.queryj.metadata.AbstractForeignKeyDecorator.java

/**
 * Compares given {@link ForeignKey foreign keys}.
 * @param first the first./*  w  w  w.j av a  2s.co m*/
 * @param second the second.
 * @return a positive number if the first is considered 'greater' than the second;
 * 0 if they are equal; a negative number otherwise.
 */
@SuppressWarnings("unchecked")
protected int compareFks(@NotNull final ForeignKey<String> first,
        @NotNull final ForeignKey<DecoratedString> second) {
    final int result;

    @NotNull
    final CompareToBuilder comparator = new CompareToBuilder();

    comparator.append(first.getSourceTableName(), second.getSourceTableName().getValue());

    comparator.append(first.getTargetTableName(), second.getTargetTableName().getValue());

    comparator.append(first.isNullable(), second.isNullable());

    final List<Attribute<String>> t_lFirstAttributes = first.getAttributes();
    final List<Attribute<DecoratedString>> t_lSecondAttributes = second.getAttributes();

    final Attribute<String>[] t_aFirstAttributes = (Attribute<String>[]) new Attribute<?>[t_lFirstAttributes
            .size()];
    t_lFirstAttributes.toArray(t_aFirstAttributes);
    final Attribute<DecoratedString>[] t_aSecondAttributes = (Attribute<DecoratedString>[]) new Attribute<?>[t_lSecondAttributes
            .size()];
    t_lSecondAttributes.toArray(t_aSecondAttributes);

    for (int t_iIndex = 0; t_iIndex < t_aFirstAttributes.length; t_iIndex++) {
        if (t_iIndex < t_aSecondAttributes.length) {
            comparator.append(t_aFirstAttributes[t_iIndex], t_aSecondAttributes[t_iIndex]);
        }
    }

    result = comparator.toComparison();

    return result;
}

From source file:org.acmsl.queryj.metadata.vo.AbstractForeignKey.java

/**
 * Compares given {@link ForeignKey foreign keys}.
 * @param first the first.//from w w w . j av a 2s. c om
 * @param second the second.
 * @return a positive number if the first is considered 'greater' than the second;
 * 0 if they are equal; a negative number otherwise.
 */
@SuppressWarnings("unchecked")
protected int compareThem(@NotNull final ForeignKey<V> first, @NotNull final ForeignKey<V> second) {
    final int result;

    @NotNull
    final CompareToBuilder comparator = new CompareToBuilder();

    comparator.append(first.getSourceTableName(), second.getSourceTableName());

    comparator.append(first.getTargetTableName(), second.getTargetTableName());

    comparator.append(first.isNullable(), second.isNullable());

    final List<Attribute<V>> t_lFirstAttributes = first.getAttributes();
    final List<Attribute<V>> t_lSecondAttributes = second.getAttributes();

    final Attribute<V>[] t_aFirstAttributes = (Attribute<V>[]) new Attribute<?>[t_lFirstAttributes.size()];
    t_lFirstAttributes.toArray(t_aFirstAttributes);
    final Attribute<V>[] t_aSecondAttributes = (Attribute<V>[]) new Attribute<?>[t_lSecondAttributes.size()];
    t_lSecondAttributes.toArray(t_aSecondAttributes);

    for (int t_iIndex = 0; t_iIndex < t_aFirstAttributes.length; t_iIndex++) {
        if (t_iIndex < t_aSecondAttributes.length) {
            comparator.append(t_aFirstAttributes[t_iIndex], t_aSecondAttributes[t_iIndex]);
        }
    }

    result = comparator.toComparison();

    return result;
}

From source file:org.apache.rya.accumulo.mr.RyaStatementWritable.java

/**
 * Comparison method for natural ordering. Compares based on the logical
 * triple (the s/p/o/context information in the underlying RyaStatement)
 * and then by the metadata contained in the RyaStatement if the triples are
 * the same.//from www .j  av  a 2  s.c  o m
 * @return  Zero if both RyaStatementWritables contain equivalent statements
 *          or both have null statements; otherwise, an integer whose sign
 *          corresponds to a consistent ordering.
 */
@Override
public int compareTo(RyaStatementWritable other) {
    CompareToBuilder builder = new CompareToBuilder();
    RyaStatement rsThis = this.getRyaStatement();
    RyaStatement rsOther = other.getRyaStatement(); // should throw NPE if other is null, as per Comparable contract
    builder.append(rsThis == null, rsOther == null);
    if (rsThis != null && rsOther != null) {
        builder.append(rsThis.getSubject(), rsOther.getSubject());
        builder.append(rsThis.getPredicate(), rsOther.getPredicate());
        builder.append(rsThis.getObject(), rsOther.getObject());
        builder.append(rsThis.getContext(), rsOther.getContext());
        builder.append(rsThis.getQualifer(), rsOther.getQualifer());
        builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility());
        builder.append(rsThis.getValue(), rsOther.getValue());
        builder.append(rsThis.getTimestamp(), rsOther.getTimestamp());
    }
    return builder.toComparison();
}

From source file:org.diffkit.db.DKDBTypeInfo.java

public int compareTo(DKDBTypeInfo target_) {
    CompareToBuilder builder = new CompareToBuilder();

    builder.append(_javaSqlType, target_._javaSqlType);

    return builder.toComparison();
}

From source file:org.geoserver.security.iride.entity.IrideIdentity.java

@Override
public int compareTo(IrideIdentity other) {
    // quick test
    if (this == other) {
        return 0;
    }//  w w w .ja  v  a  2 s.  co  m

    final CompareToBuilder builder = new CompareToBuilder();
    builder.append(this.codFiscale, other.codFiscale).append(this.nome, other.nome)
            .append(this.cognome, other.cognome).append(this.idProvider, other.idProvider)
            .append(this.timestamp, other.timestamp)
            .append(this.livelloAutenticazione, other.livelloAutenticazione).append(this.mac, other.mac);

    return builder.toComparison();
}

From source file:org.geoserver.security.iride.entity.IrideInfoPersona.java

@Override
public int compareTo(IrideInfoPersona other) {
    // quick test
    if (this == other) {
        return 0;
    }//from  w ww.java2s . c  o  m

    final CompareToBuilder builder = new CompareToBuilder();
    builder.append(this.role, other.role);

    return builder.toComparison();
}

From source file:org.geoserver.security.iride.entity.IrideRole.java

@Override
public int compareTo(IrideRole other) {
    // quick test
    if (this == other) {
        return 0;
    }/*from   ww  w.  j a  v  a2s  .  c om*/

    final CompareToBuilder builder = new CompareToBuilder();
    builder.append(this.code, this.domain);

    return builder.toComparison();
}

From source file:org.glite.security.voms.admin.persistence.model.Certificate.java

public int compareTo(Certificate o) {

    CompareToBuilder builder = new CompareToBuilder();

    builder.append(subjectString, o.subjectString).append(ca.getSubjectString(), o.ca.getSubjectString());

    return builder.toComparison();
}