Java 类com.google.common.collect.ComparisonChain 实例源码

项目:catpeds    文件:PedigreeComparator.java   
/**
 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 */
@Override
public int compare(Pedigree o1, Pedigree o2) {
    int result = ComparisonChain.start()
    .compare(o1.getId(), o2.getId())
    .compare(o1.getTitle(), o2.getTitle(), Ordering.natural().nullsFirst())
    .compare(o1.getName(), o2.getName(), Ordering.natural().nullsFirst())
    .compare(o1.getGender(), o2.getGender(), Ordering.natural().nullsFirst())
    .compare(o1.getEms(), o2.getEms(), Ordering.natural().nullsFirst())
    .compare(o1.getDob(), o2.getDob(), Ordering.natural().nullsFirst())
    .compare(o1.getInbreeding(), o2.getInbreeding())
    .compare(o1.getDamId(), o2.getDamId(), Ordering.natural().nullsFirst())
    .compare(o1.getSireId(), o2.getSireId(), Ordering.natural().nullsFirst())
    .compare(o1.getLocationCountryCode(), o2.getLocationCountryCode(), Ordering.natural().nullsFirst())
    .compare(o1.getNationalityCountryCode(), o2.getNationalityCountryCode(), Ordering.natural().nullsFirst())
    .compare(o1.getOffsprings().size(), o2.getOffsprings().size())
    .result();
    if (result != 0) {
        return result;
    }
    Set<Long> offsprings = o1.getOffsprings();
    offsprings.removeAll(o2.getOffsprings());
    return offsprings.isEmpty() ? 0 : -1; // simplifying - not comparing id's in the sets
}
项目:empiria.player    文件:ResponseResultVariables.java   
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (!(obj instanceof ResultVariables)) {
        return false;
    }
    ResultVariables other = (ResultVariables) obj;
    if (processingResult == null) {
        return false;
    }
    return ComparisonChain.start().compare(getTodo(), other.getTodo()).compare(getDone(), other.getDone()).compare(getErrors(), other.getErrors())
            .compare(getMistakes(), other.getMistakes()).compare(getLastMistaken(), other.getLastMistaken()).result() == 0;
}
项目:tac-kbp-eal    文件:ByJustificationLocation.java   
@Override
public int compare(final Answerable left, final Answerable right) {
  final Optional<Response> earliestLeftResponse = earliestResponse(left);
  final Optional<Response> earliestRightResponse = earliestResponse(right);

  if (earliestLeftResponse.isPresent()) {
    if (earliestRightResponse.isPresent()) {
      return ComparisonChain.start()
          .compare(earliestLeftResponse.get(), earliestRightResponse.get(),
              Response.ByJustificationLocation)
          .compare(left, right)
          .result();
    } else {
      return -1;
    }
  } else if (earliestRightResponse.isPresent()) {
    return 1;
  } else {
    return left.compareTo(right);
  }
}
项目:metanome-algorithms    文件:DatatypeString.java   
public DatatypeString(final Comparator<String> comparator) {
  this.specificType = type.STRING;

  if (comparator == null) {
    this.indexedComparator = new Comparator<RowIndexedStringValue>() {

      @Override
      public int compare(final RowIndexedStringValue o1, final RowIndexedStringValue o2) {
        return ComparisonChain.start()
            .compare(o1.value, o2.value, Ordering.natural().nullsFirst()).result();
      }

    };
  } else {
    this.indexedComparator = new Comparator<RowIndexedStringValue>() {

      @Override
      public int compare(final RowIndexedStringValue o1, final RowIndexedStringValue o2) {
        return ComparisonChain.start()
            .compare(o1.value, o2.value, Ordering.from(comparator).nullsFirst()).result();
      }

    };
  }

}
项目:metanome-algorithms    文件:DatatypeDate.java   
public DatatypeDate(final Comparator<Date> comparator, final String dateFormat) {
  this.specificType = type.DATE;
  this.setDateFormat(dateFormat);

  if (comparator == null) {
    this.indexedComparator = new Comparator<RowIndexedDateValue>() {

      @Override
      public int compare(final RowIndexedDateValue o1, final RowIndexedDateValue o2) {
        return ComparisonChain.start()
            .compare(o1.value, o2.value, Ordering.natural().nullsFirst()).result();
      }

    };
  } else {
    this.indexedComparator = new Comparator<RowIndexedDateValue>() {

      @Override
      public int compare(final RowIndexedDateValue o1, final RowIndexedDateValue o2) {
        return ComparisonChain.start()
            .compare(o1.value, o2.value, Ordering.from(comparator).nullsFirst()).result();
      }

    };
  }
}
项目:metanome-algorithms    文件:DatatypeDouble.java   
public DatatypeDouble(final Comparator<Double> comparator) {
  this.specificType = type.DOUBLE;

  if (comparator == null) {
    this.indexedComparator = new Comparator<RowIndexedDoubleValue>() {

      @Override
      public int compare(final RowIndexedDoubleValue o1, final RowIndexedDoubleValue o2) {
        return ComparisonChain.start()
            .compare(o1.value, o2.value, Ordering.natural().nullsFirst()).result();
      }

    };
  } else {
    this.indexedComparator = new Comparator<RowIndexedDoubleValue>() {

      @Override
      public int compare(final RowIndexedDoubleValue o1, final RowIndexedDoubleValue o2) {
        return ComparisonChain.start()
            .compare(o1.value, o2.value, Ordering.from(comparator).nullsFirst()).result();
      }

    };
  }

}
项目:ontolib    文件:GoGaf21Annotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof GoGaf21Annotation)) {
    throw new OntoLibRuntimeException(
        "Can only compare GoGaf21Annotation with objects of same type");
  }
  GoGaf21Annotation that = (GoGaf21Annotation) o;

  return ComparisonChain.start().compare(this.annotationExtension, that.annotationExtension)
      .compare(this.aspect, that.aspect).compare(this.assignedBy, that.assignedBy)
      .compare(this.date, that.date).compare(this.db, that.db)
      .compare(this.dbObjectId, that.dbObjectId).compare(this.dbObjectName, that.dbObjectName)
      .compare(this.dbObjectSymbol, that.dbObjectSymbol)
      .compare(this.dbObjectSynonym, that.dbObjectSynonym)
      .compare(this.dbObjectType, that.dbObjectType).compare(this.dbReference, that.dbReference)
      .compare(this.evidenceCode, that.evidenceCode)
      .compare(this.geneProductFormId, that.geneProductFormId).compare(this.goId, that.goId)
      .compare(this.qualifier, that.qualifier)
      .compare(this.taxons, that.taxons, Ordering.<String>natural().lexicographical())
      .compare(this.with, that.with).result();
}
项目:boqa    文件:GoGaf21Annotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof GoGaf21Annotation)) {
    throw new OntoLibRuntimeException(
        "Can only compare GoGaf21Annotation with objects of same type");
  }
  GoGaf21Annotation that = (GoGaf21Annotation) o;

  return ComparisonChain.start().compare(this.annotationExtension, that.annotationExtension)
      .compare(this.aspect, that.aspect).compare(this.assignedBy, that.assignedBy)
      .compare(this.date, that.date).compare(this.db, that.db)
      .compare(this.dbObjectId, that.dbObjectId).compare(this.dbObjectName, that.dbObjectName)
      .compare(this.dbObjectSymbol, that.dbObjectSymbol)
      .compare(this.dbObjectSynonym, that.dbObjectSynonym)
      .compare(this.dbObjectType, that.dbObjectType).compare(this.dbReference, that.dbReference)
      .compare(this.evidenceCode, that.evidenceCode)
      .compare(this.geneProductFormId, that.geneProductFormId).compare(this.goId, that.goId)
      .compare(this.qualifier, that.qualifier)
      .compare(this.taxons, that.taxons, Ordering.<String>natural().lexicographical())
      .compare(this.with, that.with).result();
}
项目:boqa    文件:HpoDiseaseAnnotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof HpoDiseaseAnnotation)) {
    throw new OntoLibRuntimeException(
        "Can only compare HPODiseaseAnnotation with objects of same type");
  }
  HpoDiseaseAnnotation that = (HpoDiseaseAnnotation) o;

  return ComparisonChain.start().compare(this.db, that.db)
      .compare(this.dbObjectId, that.dbObjectId).compare(this.dbName, that.dbName)
      .compare(this.qualifier, that.qualifier).compare(this.hpoId, that.hpoId)
      .compare(this.dbReference, that.dbReference)
      .compare(this.evidenceDescription, that.evidenceDescription)
      .compare(this.onsetModifier, that.onsetModifier).compare(this.with, that.with)
      .compare(this.aspect, that.aspect).compare(this.synonym, that.synonym)
      .compare(this.date, that.date).compare(this.assignedBy, that.assignedBy).result();
}
项目:n4js    文件:ControlFlowEdge.java   
/** There should be no two edges with same start and end nodes. */
@Override
public int compareTo(ControlFlowEdge edge) {
    int result = ComparisonChain.start()
            .compare(start.id, edge.start.id)
            .compare(end.id, edge.end.id)
            .result();

    return result;
}
项目:n4js    文件:EdgeGuideQueue.java   
private int compareForRemoveFirst(EdgeGuide eg1, EdgeGuide eg2) {
    return ComparisonChain.start()
            .compare(eg1, eg2, EdgeGuideQueue::compareASTPosition)
            .compare(eg1, eg2, EdgeGuideQueue::compareDeadFlowContext)
            .compare(eg1, eg2, EdgeGuideQueue::compareFinallyContext)
            .result();
}
项目:SensorThingsProcessor    文件:ProcessorBatchAggregate.java   
@Override
public int compareTo(AggregateCombo o) {
    return ComparisonChain.start()
            .compare(level, o.level)
            .compare(baseName, o.baseName)
            .result();
}
项目:SensorThingsProcessor    文件:ProcessorBatchAggregate.java   
@Override
public int compareTo(Delayed o) {
    CalculationOrder other = (CalculationOrder) o;
    return ComparisonChain.start()
            .compare(targetMillis, other.targetMillis)
            .compareTrueFirst(waiting.get(), other.waiting.get())
            .compare(combo, other.combo)
            .compare(interval.getStart(), other.interval.getStart())
            .result();
}
项目:hadoop-oss    文件:Quantile.java   
@Override
public int compareTo(Quantile other) {
  return ComparisonChain.start()
      .compare(quantile, other.quantile)
      .compare(error, other.error)
      .result();
}
项目:hadoop-oss    文件:ElasticByteBufferPool.java   
@Override
public int compareTo(Key other) {
  return ComparisonChain.start().
      compare(capacity, other.capacity).
      compare(insertionTime, other.insertionTime).
      result();
}
项目:tac-kbp-eal    文件:_Response.java   
@Override
public int compare(final Response left, final Response right) {
  return ComparisonChain.start()
      .compare(left.docID().toString(), right.docID().toString())
      .compare(
          Ordering.natural().sortedCopy(left.predicateJustifications()),
          Ordering.natural().sortedCopy(right.predicateJustifications()),
          Ordering.<CharOffsetSpan>natural().lexicographical())
      .compare(left.baseFiller(), right.baseFiller())
      .compare(left.canonicalArgument().charOffsetSpan(),
          right.canonicalArgument().charOffsetSpan())
      .compare(left.realis(), right.realis())
      .result();
}
项目:tac-kbp-eal    文件:_TypeRoleFillerRealis.java   
@Override
public int compareTo(final TypeRoleFillerRealis o) {
  return ComparisonChain.start()
      .compare(docID().toString(), o.docID().toString())
      .compare(type().toString(), o.type().toString())
      .compare(role().toString(), o.type().toString())
      .compare(realis(), o.realis())
      .compare(argumentCanonicalString(), argumentCanonicalString())
      .result();
}
项目:metanome-algorithms    文件:SortedPartitionCreatorTest.java   
@Test
public void testCreatePartitionFromLongtypeCustomComparator() {
  // Setup
  final Comparator<Long> longComparator = new Comparator<Long>() {
    @Override
    public int compare(final Long first, final Long second) {
      // inverse natural ordering
      return ComparisonChain.start().compare(first, second).result() * (-1);
    }
  };
  final Datatype type = new DatatypeLong(longComparator);
  // Expected values
  final ArrayList<SortedPartition> expectedSortedPartitions = new ArrayList<>();
  // reverse natural ordering: expect same equivalence classes in reverse order
  final SortedPartition firstSortedPartition = new SortedPartition(this.numRows);
  this.addEquivalenceClass(firstSortedPartition, 1L, 2L);
  this.addEquivalenceClass(firstSortedPartition, 0L);
  expectedSortedPartitions.add(firstSortedPartition);

  final SortedPartition secondSortedPartition = new SortedPartition(this.numRows);
  this.addEquivalenceClass(secondSortedPartition, 0L, 2L);
  this.addEquivalenceClass(secondSortedPartition, 1L);
  expectedSortedPartitions.add(secondSortedPartition);

  final SortedPartition thirdSortedPartition = new SortedPartition(this.numRows);
  this.addEquivalenceClass(thirdSortedPartition, 2L);
  this.addEquivalenceClass(thirdSortedPartition, 0L, 1L);
  expectedSortedPartitions.add(thirdSortedPartition);
  // Execute functionality
  // Check result
  for (int i = 0; i < this.columnIndicesLong.length; i++) {
    final SortedPartition sortedPartition =
        SortedPartitionCreator.createPartition(this.data.get(this.columnIndicesLong[i]), type);
    assertEquals(sortedPartition, expectedSortedPartitions.get(i));
  }

}
项目:kafka-connect-cassandra    文件:ConnectSchemaBuilder.java   
@Override
public int compareTo(CassandraSchemaKey that) {
  return ComparisonChain.start()
      .compare(this.keyspace, that.keyspace)
      .compare(this.tableName, that.tableName)
      .result();
}
项目:ontolib    文件:HpoGeneAnnotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof HpoGeneAnnotation)) {
    throw new RuntimeException("Cannot compare " + o + " to a HpoGeneAnnotation");
  }

  final HpoGeneAnnotation that = (HpoGeneAnnotation) o;
  return ComparisonChain.start().compare(this.entrezGeneId, that.entrezGeneId)
      .compare(this.entrezGeneSymbol, that.entrezGeneSymbol)
      .compare(this.hpoTermName, that.hpoTermName).compare(this.hpoTermId, that.hpoTermId)
      .result();
}
项目:ditb    文件:TestRegionSplitCalculator.java   
@Override
public int compare(SimpleRange sr1, SimpleRange sr2) {
  ComparisonChain cc = ComparisonChain.start();
  cc = cc.compare(sr1.getStartKey(), sr2.getStartKey(),
      Bytes.BYTES_COMPARATOR);
  cc = cc.compare(sr1.getEndKey(), sr2.getEndKey(),
      RegionSplitCalculator.BYTES_COMPARATOR);
  cc = cc.compare(sr1.tiebreaker, sr2.tiebreaker);
  return cc.result();
}
项目:ontolib    文件:UberphenoGeneAnnotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof UberphenoGeneAnnotation)) {
    throw new RuntimeException("Cannot compare " + o + " to a UberphenoGeneAnnotation");
  }

  final UberphenoGeneAnnotation that = (UberphenoGeneAnnotation) o;
  return ComparisonChain.start().compare(this.entrezGeneId, that.entrezGeneId)
      .compare(this.termId, that.termId).result();
}
项目:ontolib    文件:VegetableRecipeAnnotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof VegetableRecipeAnnotation)) {
    throw new RuntimeException("Cannot compare " + o + " to " + this);
  }
  VegetableRecipeAnnotation that = (VegetableRecipeAnnotation) o;

  return ComparisonChain.start().compare(this.termId, that.termId).compare(this.label, that.label)
      .result();
}
项目:ontolib    文件:TestTermAnnotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof TestTermAnnotation)) {
    throw new OntoLibRuntimeException("Cannot compare " + o + " to " + this);
  }
  TestTermAnnotation that = (TestTermAnnotation) o;

  return ComparisonChain.start().compare(this.termId, that.termId).compare(this.label, that.label)
      .result();
}
项目:living-documentation    文件:DomainObject.java   
@Override
public int compareTo(DomainObject o) {
    return new Ordering<DomainObject>() {
        @Override
        public int compare(DomainObject left, DomainObject right) {
            return ComparisonChain.start()
                    .compare(left.id, right.id, Ordering.natural().nullsFirst())
                    .compare(left.name, right.name, Ordering.natural().nullsFirst())
                    .compare(left.description, right.description, Ordering.natural().nullsFirst())
                    .result();
        }
    }.nullsFirst()
            .compare(this, o);
}
项目:ProjectAres    文件:MapInfo.java   
@Override
public int compareTo(MapInfo o) {
    return ComparisonChain.start()
        .compare(name, o.name)
        .compare(edition(), o.edition())
        .compare(phase(), o.phase())
        .result();
}
项目:ProjectAres    文件:JoinResult.java   
@Override
default int compareTo(JoinResult that) {
    return ComparisonChain.start()
        .compareFalseFirst(this.isFallback(), that.isFallback()) // Anything is better than this
        .compareFalseFirst(this.isAllowed(), that.isAllowed()) // Deny overrides allow
        .compareFalseFirst(this.priorityKickRequired(), that.priorityKickRequired()) // Avoid kick if possible
        .compareTrueFirst(this.isRejoin(), that.isRejoin()) // Rejoin is preferred
        .result();
}
项目:ProjectAres    文件:PlayerOrderCache.java   
@Inject PlayerOrderCache(IdentityProvider identityProvider, BukkitUserStore userStore, MinecraftService minecraftService) {

        prioritiesByPlayer = CacheUtils.newWeakKeyCache(player -> userStore
            .getUser(player)
            .minecraft_flair()
            .stream()
            .filter(flair -> minecraftService.getLocalServer().realms().contains(flair.realm))
            .map(flair -> flair.priority)
            .min(Integer::compare)
            .orElse(Integer.MAX_VALUE)
        );

        comparatorsByViewer = CacheUtils.newWeakKeyCache(strongViewer -> {
            final WeakReference<CommandSender> weakViewer = new WeakReference<>(strongViewer);
            return (a, b) -> {
                // Do not reference strongViewer in here
                final CommandSender viewer = weakViewer.get();
                if(viewer == null) return 0;

                final Identity aIdentity = identityProvider.currentIdentity(a);
                final Identity bIdentity = identityProvider.currentIdentity(b);
                return ComparisonChain.start()
                    .compareTrueFirst(a == viewer, b == viewer)
                    .compareTrueFirst(aIdentity.isFriend(viewer), bIdentity.isFriend(viewer))
                    .compare(priority(a, aIdentity, viewer), priority(b, bIdentity, viewer))
                    .compare(aIdentity.getName(viewer), bIdentity.getName(viewer), String::compareToIgnoreCase)
                    .result();
            };
        });
    }
项目:instalint    文件:PluginInfo.java   
@Override
public int compareTo(PluginInfo that) {
  return ComparisonChain.start()
    .compare(this.name, that.name)
    .compare(this.version, that.version, Ordering.natural().nullsFirst())
    .result();
}
项目:dremio-oss    文件:Upgrade.java   
@Override
public int compare(Version left, Version right) {
  return ComparisonChain.start()
      .compare(left.getMajorVersion(), right.getMajorVersion())
      .compare(left.getMinorVersion(), right.getMinorVersion())
      .compare(left.getPatchVersion(), right.getPatchVersion())
      .compare(left.getBuildNumber(), right.getBuildNumber())
      .result();
}
项目:fpm    文件:AlternateName.java   
@Override
public int compareTo(AlternateName other) {
    return ComparisonChain.start()//
            .compareTrueFirst(isPreferredName(), other.isPreferredName())//
            .compareFalseFirst(isHistoric(), other.isHistoric())//
            .compareFalseFirst(isShortName(), other.isShortName())//
            .compareFalseFirst(isColloquial(), other.isColloquial())//
            .compare(value, other.getValue()).result();
}
项目:Elasticsearch    文件:FunctionIdent.java   
@Override
public int compareTo(FunctionIdent o) {
    return ComparisonChain.start()
            .compare(name, o.name)
            .compare(argumentTypes, o.argumentTypes, Ordering.<DataType>natural().lexicographical())
            .result();
}
项目:Elasticsearch    文件:FunctionInfo.java   
@Override
public int compareTo(FunctionInfo o) {
    return ComparisonChain.start()
            .compare(type, o.type)
            .compare(ident, o.ident)
            .compare(returnType, o.returnType)
            .compare(deterministic, o.deterministic)
            .compare(comparisonReplacementPossible, o.comparisonReplacementPossible)
            .result();
}
项目:Elasticsearch    文件:ColumnIdent.java   
@Override
public int compareTo(ColumnIdent o) {
    return ComparisonChain.start()
            .compare(name, o.name)
            .compare(path, o.path, ordering)
            .result();
}
项目:RDF2PT    文件:TripleComparator.java   
@Override
public int compare(Triple t1, Triple t2) {
    return ComparisonChain.start()
    .compare(t1.getSubject(), t2.getSubject(), nodeComparator)
    .compare(t1.getPredicate(), t2.getPredicate(), nodeComparator)
    .compare(t1.getObject(), t2.getObject(), nodeComparator)
    .result();
}
项目:bazel-tools    文件:MavenDependency.java   
@Override
public int compareTo(@Nonnull final MavenDependency that) {
  return ComparisonChain.start()
      .compare(this.coords(), that.coords())
      .compare(this.version(), that.version())
      .result();
}
项目:bazel-tools    文件:MavenCoords.java   
@Override
public int compareTo(final MavenCoords that) {
  return ComparisonChain.start()
      .compare(this.groupId(), that.groupId())
      .compare(this.artifactId(), that.artifactId())
      .result();
}
项目:boqa    文件:HpoGeneAnnotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof HpoGeneAnnotation)) {
    throw new RuntimeException("Cannot compare " + o + " to a HpoGeneAnnotation");
  }

  final HpoGeneAnnotation that = (HpoGeneAnnotation) o;
  return ComparisonChain.start().compare(this.entrezGeneId, that.entrezGeneId)
      .compare(this.entrezGeneSymbol, that.entrezGeneSymbol)
      .compare(this.hpoTermName, that.hpoTermName).compare(this.hpoTermId, that.hpoTermId)
      .result();
}
项目:boqa    文件:UberphenoGeneAnnotation.java   
@Override
public int compareTo(TermAnnotation o) {
  if (!(o instanceof UberphenoGeneAnnotation)) {
    throw new RuntimeException("Cannot compare " + o + " to a UberphenoGeneAnnotation");
  }

  final UberphenoGeneAnnotation that = (UberphenoGeneAnnotation) o;
  return ComparisonChain.start().compare(this.entrezGeneId, that.entrezGeneId)
      .compare(this.termId, that.termId).result();
}
项目:boqa    文件:ImmutableEdge.java   
@Override
public int compareTo(Edge<V> o) {
  if (!(o instanceof ImmutableEdge)) {
    throw new OntoLibRuntimeException("Cannot compare " + o + " to " + this);
  }
  ImmutableEdge<V> that = (ImmutableEdge<V>) o;

  return ComparisonChain.start().compare(this.source, that.source).compare(this.dest, that.dest)
      .result();
}