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

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

Introduction

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

Prototype

public CompareToBuilder() 

Source Link

Document

Constructor for CompareToBuilder.

Starts off assuming that the objects are equal.

Usage

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

/**
 * Compares given {@link ForeignKey foreign keys}.
 * @param first the first./*from w w w. j a v  a  2 s.  c  o  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. ja  v a2 s  .c  o 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 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.andromda.timetracker.vo.TaskVO.java

/**
 * @param object to compare this object against
 * @return int if equal//from  w  w  w  .jav  a 2  s .  c  o  m
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final TaskVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    return new CompareToBuilder().append(this.getId(), object.getId()).append(this.getName(), object.getName())
            .toComparison();
}

From source file:org.andromda.timetracker.vo.TimeAllocationVO.java

/**
 * @param object to compare this object against
 * @return int if equal/*w w w. j  a  v  a 2 s .co  m*/
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final TimeAllocationVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    return new CompareToBuilder().append(this.getId(), object.getId())
            .append(this.getTimePeriodVO(), object.getTimePeriodVO())
            .append(this.getTaskId(), object.getTaskId()).toComparison();
}

From source file:org.andromda.timetracker.vo.TimecardSearchCriteriaVO.java

/**
 * @param object to compare this object against
 * @return int if equal//from  w  ww .j a v  a 2 s .  c  om
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final TimecardSearchCriteriaVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    return new CompareToBuilder().append(this.getSubmitterId(), object.getSubmitterId())
            .append(this.getApproverId(), object.getApproverId()).append(this.getStatus(), object.getStatus())
            .append(this.getStartDateMin(), object.getStartDateMin())
            .append(this.getStartDateMax(), object.getStartDateMax()).toComparison();
}

From source file:org.andromda.timetracker.vo.TimecardSummaryVO.java

/**
 * @param object to compare this object against
 * @return int if equal/*from  w  w  w.j  av  a2s.c  o  m*/
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final TimecardSummaryVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    return new CompareToBuilder().append(this.getId(), object.getId())
            .append(this.getStatus(), object.getStatus()).append(this.getStartDate(), object.getStartDate())
            .append(this.getComments(), object.getComments())
            .append(this.getSubmitterName(), object.getSubmitterName())
            .append(this.getApproverName(), object.getApproverName()).toComparison();
}

From source file:org.andromda.timetracker.vo.TimecardVO.java

/**
 * @param object to compare this object against
 * @return int if equal/* w w w.j  ava 2  s . com*/
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final TimecardSummaryVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    if (!(object instanceof TimecardVO)) {
        return -1;
    }
    TimecardVO myClass = (TimecardVO) object;
    return new CompareToBuilder().appendSuper(super.compareTo(object))
            .append(this.getAllocations(), myClass.getAllocations()).toComparison();
}

From source file:org.andromda.timetracker.vo.TimePeriodVO.java

/**
 * @param object to compare this object against
 * @return int if equal/*from  w w  w.  j a  v a  2  s.  c  o m*/
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final TimePeriodVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    return new CompareToBuilder().append(this.getStartTime(), object.getStartTime())
            .append(this.getEndTime(), object.getEndTime()).toComparison();
}

From source file:org.andromda.timetracker.vo.UserDetailsVO.java

/**
 * @param object to compare this object against
 * @return int if equal//from w  ww  .j  a  v  a2 s .  c  o  m
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final UserVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    if (!(object instanceof UserDetailsVO)) {
        return -1;
    }
    UserDetailsVO myClass = (UserDetailsVO) object;
    return new CompareToBuilder().appendSuper(super.compareTo(object))
            .append(this.getPassword(), myClass.getPassword()).append(this.getEmail(), myClass.getEmail())
            .append(this.isIsActive(), myClass.isIsActive())
            .append(this.getCreationDate(), myClass.getCreationDate())
            .append(this.getComment(), myClass.getComment()).append(this.getRoles(), myClass.getRoles())
            .toComparison();
}

From source file:org.andromda.timetracker.vo.UserRoleVO.java

/**
 * @param object to compare this object against
 * @return int if equal/*from   ww w . ja  v a 2s  . c  o m*/
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final UserRoleVO object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    return new CompareToBuilder().append(this.getId(), object.getId()).append(this.getRole(), object.getRole())
            .toComparison();
}