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:core.messaging.Destination.java

public int compareTo(Object o) {
    Destination rhs = (Destination) o;
    return new CompareToBuilder().append(address, rhs.address).append(type, rhs.type).append(user, rhs.user)
            .toComparison();//from   w  w w  .j  a v a2 s.  c om
}

From source file:eu.debooy.natuur.domain.TaxonDto.java

public int compareTo(TaxonDto taxonDto) {
    return new CompareToBuilder().append(taxonId, taxonDto.taxonId).toComparison();
}

From source file:net.sf.sze.model.zeugnisconfig.Schulhalbjahr.java

@Override
public int compareTo(final Schulhalbjahr other) {
    final CompareToBuilder compareBuilder = new CompareToBuilder();
    compareBuilder.append(this.jahr, other.jahr);
    compareBuilder.append(this.halbjahr, other.halbjahr);
    compareBuilder.append(this.selectable, other.selectable);
    return compareBuilder.toComparison();
}

From source file:edu.utah.further.mdr.data.common.domain.asset.AbstractVersionEntity.java

/**
 * @param other/*from   ww w  . j  a  v  a 2s . c o  m*/
 * @return
 * @see edu.utah.further.mdr.api.domain.asset.Version#compareTo(edu.utah.further.mdr.api.domain.asset.Version)
 */
@Override
public int compareTo(final Version other) {
    return new CompareToBuilder().append(this.version, other.getVersion()).toComparison();
}

From source file:com.hmsinc.epicenter.model.workflow.Activity.java

public int compareTo(Activity rhs) {
    return new CompareToBuilder().append(timestamp, rhs.getTimestamp()).append(id, rhs.getId()).toComparison();
}

From source file:br.com.ingenieux.mojo.beanstalk.version.CleanPreviousVersionsMojo.java

@Override
protected Object executeInternal() throws MojoExecutionException, MojoFailureException {
    boolean bVersionsToKeepDefined = (null != versionsToKeep);
    boolean bDaysToKeepDefined = (null != daysToKeep);

    if (!(bVersionsToKeepDefined ^ bDaysToKeepDefined)) {
        throw new MojoFailureException("Declare either versionsToKeep or daysToKeep, but not both nor none!");
    }/*from  www .jav a 2 s. c o  m*/

    DescribeApplicationVersionsRequest describeApplicationVersionsRequest = new DescribeApplicationVersionsRequest()
            .withApplicationName(applicationName);

    DescribeApplicationVersionsResult appVersions = getService()
            .describeApplicationVersions(describeApplicationVersionsRequest);

    DescribeEnvironmentsResult environments = getService().describeEnvironments();

    List<ApplicationVersionDescription> appVersionList = new ArrayList<ApplicationVersionDescription>(
            appVersions.getApplicationVersions());

    deletedVersionsCount = 0;

    for (EnvironmentDescription d : environments.getEnvironments()) {
        boolean bActiveEnvironment = (d.getStatus().equals("Running") || d.getStatus().equals("Launching")
                || d.getStatus().equals("Ready"));

        for (ListIterator<ApplicationVersionDescription> appVersionIterator = appVersionList
                .listIterator(); appVersionIterator.hasNext();) {
            ApplicationVersionDescription appVersion = appVersionIterator.next();

            boolean bMatchesVersion = appVersion.getVersionLabel().equals(d.getVersionLabel());

            if (bActiveEnvironment && bMatchesVersion) {
                getLog().info("VersionLabel " + appVersion.getVersionLabel() + " is bound to environment "
                        + d.getEnvironmentName() + " - Skipping it");

                appVersionIterator.remove();
            }
        }
    }

    filterAppVersionListByVersionLabelPattern(appVersionList, cleanFilter);

    Collections.sort(appVersionList, new Comparator<ApplicationVersionDescription>() {
        @Override
        public int compare(ApplicationVersionDescription o1, ApplicationVersionDescription o2) {
            return new CompareToBuilder().append(o1.getDateUpdated(), o2.getDateUpdated()).toComparison();
        }
    });

    if (bDaysToKeepDefined) {
        Date now = new Date();

        for (ApplicationVersionDescription d : appVersionList) {
            long delta = now.getTime() - d.getDateUpdated().getTime();

            delta /= 1000;
            delta /= 86400;

            boolean shouldDeleteP = (delta > daysToKeep);

            if (getLog().isDebugEnabled()) {
                getLog().debug("Version " + d.getVersionLabel() + " was from " + delta
                        + " days ago. Should we delete? " + shouldDeleteP);
            }

            if (shouldDeleteP) {
                deleteVersion(d);
            }
        }
    } else {
        while (appVersionList.size() > versionsToKeep) {
            deleteVersion(appVersionList.remove(0));
        }
    }

    getLog().info("Deleted " + deletedVersionsCount + " versions.");

    return null;
}

From source file:com.algoTrader.vo.ib.ExecDetails.java

/**
 * @param object to compare this object against
 * @return int if equal/*  www  .java 2  s  .c o m*/
 * @see Comparable#compareTo(Object)
 */
public int compareTo(final ExecDetails object) {
    if (object == null) {
        return -1;
    }
    // Check if the same object instance
    if (object == this) {
        return 0;
    }
    return new CompareToBuilder().append(this.getReqId(), object.getReqId())
            .append(this.getContract(), object.getContract()).append(this.getExecution(), object.getExecution())
            .toComparison();
}

From source file:net.sf.sze.model.zeugnisconfig.ZeugnisArt.java

@SuppressWarnings("boxing")
@Override/*from   ww w .  j  a  va2s . c o m*/
public int compareTo(final ZeugnisArt other) {
    final CompareToBuilder compareBuilder = new CompareToBuilder();
    compareBuilder.append(!this.aktiv, !other.aktiv);
    compareBuilder.append(this.sortierung, other.sortierung);
    compareBuilder.append(this.name, other.name);
    return compareBuilder.toComparison();
}

From source file:com.googlecode.osde.internal.editors.locale.LocaleModel.java

public int compareTo(LocaleModel o) {
    return new CompareToBuilder().append(country, o.getCountry()).append(lang, o.getLang()).toComparison();
}

From source file:gemlite.core.internal.support.context.GemliteIndexContext.java

public void putIndexNamesByTestRegion(IndexRegion bean) {
    Set<IndexRegion> list = testRegionMap.get(bean.regionName());
    if (list == null) {
        list = new ConcurrentSkipListSet<IndexRegion>(new Comparator<IndexRegion>() {

            @Override//from  w ww  .  j a va2  s  .  c  o  m
            public int compare(IndexRegion o1, IndexRegion o2) {

                return new CompareToBuilder().append(o1.orderNo(), o2.orderNo())
                        .append(o1.indexName(), o2.indexName()).toComparison();
            }
        });

        testRegionMap.put(bean.regionName(), list);
    }

    list.add(bean);
}