Example usage for com.google.common.collect ComparisonChain start

List of usage examples for com.google.common.collect ComparisonChain start

Introduction

In this page you can find the example usage for com.google.common.collect ComparisonChain start.

Prototype

public static ComparisonChain start() 

Source Link

Document

Begins a new chained comparison statement.

Usage

From source file:org.spongepowered.api.data.manipulator.immutable.common.collection.AbstractImmutableSingleSetData.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override//  w w  w.  java2  s .co m
public int compareTo(I o) {
    return ComparisonChain.start()
            .compare(o.getValue((Key<SetValue<E>>) (Key) this.usedKey).get().get().containsAll(this.getValue()),
                    this.getValue().containsAll(o.getValue((Key<SetValue<E>>) (Key) this.usedKey).get().get()))
            .result();
}

From source file:org.opencms.ade.publish.shared.CmsProjectBean.java

/**
 * @see java.lang.Comparable#compareTo(java.lang.Object)
 *///  w  ww .  j  a  v  a2  s . c o m
public int compareTo(CmsProjectBean otherProject) {

    return ComparisonChain.start().compare(m_rank, otherProject.getRank())
            .compare(m_name, otherProject.getName()).result();

}

From source file:com.facebook.buck.core.sourcepath.AbstractExplicitBuildTargetSourcePath.java

@Override
public int compareTo(SourcePath other) {
    if (other == this) {
        return 0;
    }// w  w w .j  a v a2  s. co  m

    int classComparison = compareClasses(other);
    if (classComparison != 0) {
        return classComparison;
    }

    AbstractExplicitBuildTargetSourcePath that = (AbstractExplicitBuildTargetSourcePath) other;

    return ComparisonChain.start().compare(getTarget(), that.getTarget())
            .compare(getResolvedPath(), that.getResolvedPath()).result();
}

From source file:com.facebook.buck.core.sourcepath.AbstractForwardingBuildTargetSourcePath.java

@Override
public int compareTo(SourcePath other) {
    if (other == this) {
        return 0;
    }/*from  ww  w .j  a v a2  s .  c  om*/

    int classComparison = compareClasses(other);
    if (classComparison != 0) {
        return classComparison;
    }

    AbstractForwardingBuildTargetSourcePath that = (AbstractForwardingBuildTargetSourcePath) other;

    return ComparisonChain.start().compare(getTarget(), that.getTarget())
            .compare(getDelegate(), that.getDelegate()).result();
}

From source file:controllers.GrokPatternsController.java

public Result index() {
    BreadcrumbList bc = new BreadcrumbList();
    bc.addCrumb("System", routes.SystemController.index(0));
    bc.addCrumb("Grok patterns", routes.GrokPatternsController.index());

    final Collection<GrokPatternSummary> grokPatterns;
    try {//from   w ww.j av a2s.c  o m
        grokPatterns = extractorService.allGrokPatterns();
    } catch (APIException e) {
        return internalServerError();
    } catch (IOException e) {
        return internalServerError();
    }

    final TreeSet<GrokPatternSummary> sortedPatterns = Sets.newTreeSet(new Comparator<GrokPatternSummary>() {
        @Override
        public int compare(GrokPatternSummary o1, GrokPatternSummary o2) {
            return ComparisonChain.start().compare(o1.name, o2.name).result();
        }
    });
    sortedPatterns.addAll(grokPatterns);

    return ok(views.html.system.grokpatterns.index.render(currentUser(), bc, sortedPatterns));
}

From source file:org.spongepowered.common.data.manipulator.mutable.entity.SpongeCriticalHitData.java

@Override
public int compareTo(CriticalHitData o) {
    return ComparisonChain.start().compare(getValue(), o.criticalHit().get()).result();
}

From source file:eu.eubrazilcc.lvl.core.ImmutablePair.java

@Override
public int compareTo(final ImmutablePair<L, R> other) {
    if (this == other)
        return 0;
    return ComparisonChain.start().compare(left, other.left).compare(right, other.right).result();
}

From source file:org.gradle.language.base.internal.tasks.apigen.abi.MethodSig.java

@Override
public int compareTo(MethodSig o) {
    return ComparisonChain.start().compare(access, o.access).compare(name, o.name)
            .compare(desc == null ? "" : desc, o.desc == null ? "" : o.desc)
            .compare(signature == null ? "" : signature, o.signature == null ? "" : o.signature)
            .compare(exceptions, o.exceptions, Ordering.<String>natural().lexicographical()).result();
}

From source file:net.orpiske.tcs.wc.io.OccurrenceWritable.java

private int compareTo(OccurrenceWritable o) {
    if (logger.isTraceEnabled()) {

        if (o == null) {
            logger.trace("Other object is null. Printing this only: " + toString());
        } else {//  www.ja v  a  2s. c  o  m
            logger.trace("This data: " + toString());
            logger.trace("Other data: " + o.toString());
        }
    }

    return ComparisonChain.start().compare(text, o.text).compare(domain, o.domain).result();
}

From source file:org.obiba.opal.web.gwt.app.client.magma.view.BinarySummaryView.java

public BinarySummaryView(BinarySummaryDto summaryDto) {
    initWidget(uiBinder.createAndBindUi(this));
    stats.clear();/*  ww  w .j a  va  2s . c  o m*/
    stats.setHeader(0, translations.descriptiveStatistics());
    stats.setHeader(1, translations.value());
    int row = 0;
    stats.setWidget(row, 0, new Label(translations.NLabel()));
    stats.setWidget(row++, 1, new Label("" + Math.round(summaryDto.getN())));

    if (summaryDto.getFrequenciesArray() != null) {
        int count = summaryDto.getFrequenciesArray().length();

        frequencies.setHeader(0, translations.value());
        frequencies.setHeader(1, translations.frequency());
        frequencies.setHeader(2, "%");

        List<FrequencyDto> frequencyDtos = JsArrays.toList(summaryDto.getFrequenciesArray());
        Collections.sort(frequencyDtos, new Comparator<FrequencyDto>() {
            @Override
            public int compare(FrequencyDto o1, FrequencyDto o2) {
                return ComparisonChain.start()
                        .compare(o1.getValue(), o2.getValue(), Ordering.natural().reverse()).result();
            }
        });
        // Not empty before N/A,
        for (int i = 0; i < count; i++) {
            FrequencyDto value = frequencyDtos.get(i);
            if (value.hasValue()) {
                frequencies.setWidget(i + 1, 0,
                        new Label(value.getValue().equals("NOT_NULL") ? translations.notNullStatistics()
                                : value.getValue())); // Translate N/A and NOT_NULL
                frequencies.setWidget(i + 1, 1, new Label("" + Math.round(value.getFreq())));
                frequencies.setWidget(i + 1, 2, new Label("" + formatDecimal(value.getPct() * 100)));
            }
        }
    } else {
        frequencies.clear();
    }
}