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:com.thinkbiganalytics.metadata.jpa.sla.JpaServiceLevelAssessment.java

@Override
public int compareTo(ServiceLevelAssessment sla) {

    ComparisonChain chain = ComparisonChain.start().compare(this.getResult(), sla.getResult())
            .compare(this.getAgreement().getName(), sla.getAgreement().getName());

    if (chain.result() != 0) {
        return chain.result();
    }//from w  w  w .j a v a 2  s . c om

    List<ObligationAssessment> list1 = new ArrayList<>(this.getObligationAssessments());
    List<ObligationAssessment> list2 = new ArrayList<>(sla.getObligationAssessments());

    chain = chain.compare(list1.size(), list2.size());

    Collections.sort(list1);
    Collections.sort(list2);

    for (int idx = 0; idx < list1.size(); idx++) {
        chain = chain.compare(list1.get(idx), list2.get(idx));
    }

    return chain.result();
}

From source file:org.jclouds.joyent.cloudapi.v6_5.domain.Package.java

@Override
public int compareTo(Package that) {
    return ComparisonChain.start().compare(this.name, that.name).compare(this.memorySizeMb, that.memorySizeMb)
            .compare(this.diskSizeGb, that.diskSizeGb).compare(this.swapSizeMb, that.swapSizeMb).result();
}

From source file:org.corpus_tools.annis.benchmark.generator.QuerySetViewController.java

/**
 * Initializes the controller class./*from w w  w . java 2  s. co m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    parser = new AnnisParserAntlr();
    parser.setPrecedenceBound(50);

    nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
    aqlColumn.setCellValueFactory(new PropertyValueFactory<>("aql"));
    corpusColumn.setCellValueFactory(new PropertyValueFactory<>("corpora"));
    execTimeColumn.setCellValueFactory(new PropertyValueFactory<>("executionTime"));
    nrResultsColumn.setCellValueFactory(new PropertyValueFactory<>("count"));

    nameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    aqlColumn.setCellFactory(TextAreaTableCell.forTableColumn());
    corpusColumn.setCellFactory(TextFieldTableCell.forTableColumn(new StringSetConverter()));
    execTimeColumn.setCellFactory(TextFieldTableCell.forTableColumn(new OptionalLongConverter()));
    nrResultsColumn.setCellFactory(TextFieldTableCell.forTableColumn(new OptionalLongConverter()));
    validColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getJson() != null));

    execTimeColumn.setComparator((Optional<Long> o1, Optional<Long> o2) -> ComparisonChain.start()
            .compare(o1.orElse(Long.MIN_VALUE), o2.orElse(Long.MIN_VALUE)).result());

    nameColumn.setOnEditCommit((TableColumn.CellEditEvent<Query, String> event) -> {
        event.getRowValue().setName(event.getNewValue());
    });
    aqlColumn.setOnEditCommit((TableColumn.CellEditEvent<Query, String> event) -> {
        event.getRowValue().setAql(event.getNewValue());
    });
    corpusColumn.setOnEditCommit((TableColumn.CellEditEvent<Query, Set<String>> event) -> {
        event.getRowValue().setCorpora(event.getNewValue());
    });
    execTimeColumn.setOnEditCommit((TableColumn.CellEditEvent<Query, Optional<Long>> event) -> {
        event.getRowValue().setExecutionTime(event.getNewValue());
    });
    nrResultsColumn.setOnEditCommit((TableColumn.CellEditEvent<Query, Optional<Long>> event) -> {
        event.getRowValue().setCount(event.getNewValue());
    });

    FilteredList<Query> filteredQueries = new FilteredList<>(queries);
    SortedList<Query> sortedQueries = new SortedList<>(filteredQueries);

    sortedQueries.comparatorProperty().bind(tableView.comparatorProperty());

    corpusFilter.textProperty().addListener(observable -> {
        setFilterPredicate(filteredQueries);
    });
    oneCorpusFilter.selectedProperty().addListener(observable -> {
        setFilterPredicate(filteredQueries);
    });
    onlyValidFilter.selectedProperty().addListener(observable -> {
        setFilterPredicate(filteredQueries);
    });
    onlyUniqueFilter.selectedProperty().addListener(observable -> {
        setFilterPredicate(filteredQueries);
    });

    tableView.setItems(sortedQueries);

    filteredQueries.addListener((Change<? extends Query> change) -> {
        counterLabel.textProperty().set("" + filteredQueries.size());
    });
}

From source file:com.facebook.buck.model.AbstractBuildTarget.java

@Override
public int compareTo(AbstractBuildTarget o) {
    if (this == o) {
        return 0;
    }/*from  ww  w  .j a  va2 s .c  o m*/

    return ComparisonChain.start().compare(getUnflavoredBuildTarget(), o.getUnflavoredBuildTarget())
            .compare(getFlavors(), o.getFlavors(), LEXICOGRAPHICAL_ORDERING).result();
}

From source file:org.spongepowered.common.data.manipulator.immutable.entity.ImmutableSpongeBodyPartRotationalData.java

@Override
public int compareTo(ImmutableBodyPartRotationalData o) {
    int mapSizeComp = Integer.compare(this.rotations.size(), o.partRotation().size());

    if (mapSizeComp != 0) {
        return mapSizeComp;
    }// w  ww  .j  a va 2s  .  co m
    ComparisonChain comparison = ComparisonChain.start();
    Map<BodyPart, Vector3d> parts = o.partRotation().get();
    parts.forEach((part, vec) -> {
        comparison.compare(vec, this.rotations.get(part));
    });
    return comparison.result();
}

From source file:com.wealdtech.hawk.HawkServerConfiguration.java

@Override
public int compareTo(final HawkServerConfiguration that) {
    return ComparisonChain.start().compare(this.getTimestampSkew(), that.getTimestampSkew())
            .compare(this.isBewitAllowed(), that.isBewitAllowed())
            .compare(this.getPayloadValidation(), that.getPayloadValidation())
            .compare(this.getNonceCacheSize(), that.getNonceCacheSize()).result();
}

From source file:com.tngtech.archunit.core.domain.Dependency.java

@Override
@PublicAPI(usage = ACCESS)//  w  w w.  j a va  2s  .co  m
public int compareTo(Dependency o) {
    return ComparisonChain.start().compare(lineNumber, o.lineNumber)
            .compare(getDescription(), o.getDescription()).result();
}

From source file:com.opengamma.strata.market.sensitivity.RepoCurveZeroRateSensitivity.java

@Override
public int compareKey(PointSensitivity other) {
    if (other instanceof RepoCurveZeroRateSensitivity) {
        RepoCurveZeroRateSensitivity otherZero = (RepoCurveZeroRateSensitivity) other;
        return ComparisonChain.start().compare(curveCurrency, otherZero.curveCurrency)
                .compare(currency, otherZero.currency).compare(date, otherZero.date)
                .compare(bondGroup, otherZero.bondGroup).result();
    }/*w w w. ja  v a2  s . c  o m*/
    return getClass().getSimpleName().compareTo(other.getClass().getSimpleName());
}

From source file:com.android.tools.idea.avdmanager.SystemImageList.java

private static boolean isBetter(@NotNull SystemImageDescription image,
        @Nullable SystemImageDescription bestSoFar) {
    return bestSoFar == null || 0 < ComparisonChain.start()
            .compareTrueFirst(image.isRemote(), bestSoFar.isRemote())
            .compare(abiRank(image), abiRank(bestSoFar)).compare(image.getVersion(), bestSoFar.getVersion())
            .compareFalseFirst(image.getTag().equals(GOOGLE_APIS_TAG),
                    bestSoFar.getTag().equals(GOOGLE_APIS_TAG))
            .result();/*  w  w  w  . j  a v  a 2 s . com*/
}

From source file:com.opengamma.strata.market.sensitivity.OvernightRateSensitivity.java

@Override
public int compareKey(PointSensitivity other) {
    if (other instanceof OvernightRateSensitivity) {
        OvernightRateSensitivity otherOn = (OvernightRateSensitivity) other;
        return ComparisonChain.start().compare(index.toString(), otherOn.index.toString())
                .compare(currency, otherOn.currency).compare(fixingDate, otherOn.fixingDate)
                .compare(endDate, otherOn.endDate).result();
    }//from  w ww  .  j a va  2 s . c om
    return getClass().getSimpleName().compareTo(other.getClass().getSimpleName());
}