本文整理匯總了Java中com.google.common.collect.ComparisonChain類的典型用法代碼示例。如果您正苦於以下問題:Java ComparisonChain類的具體用法?Java ComparisonChain怎麽用?Java ComparisonChain使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ComparisonChain類屬於com.google.common.collect包,在下文中一共展示了ComparisonChain類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compare
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
/**
* @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
}
示例2: equals
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@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;
}
示例3: compare
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@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);
}
}
示例4: DatatypeString
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
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();
}
};
}
}
示例5: DatatypeDate
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
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();
}
};
}
}
示例6: DatatypeDouble
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
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();
}
};
}
}
示例7: compareTo
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@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();
}
示例8: compareTo
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@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();
}
示例9: compareTo
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
/** 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;
}
示例10: compareForRemoveFirst
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
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();
}
示例11: compareTo
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@Override
public int compareTo(AggregateCombo o) {
return ComparisonChain.start()
.compare(level, o.level)
.compare(baseName, o.baseName)
.result();
}
示例12: compareTo
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@Override
public int compareTo(Quantile other) {
return ComparisonChain.start()
.compare(quantile, other.quantile)
.compare(error, other.error)
.result();
}
示例13: compareTo
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@Override
public int compareTo(Key other) {
return ComparisonChain.start().
compare(capacity, other.capacity).
compare(insertionTime, other.insertionTime).
result();
}
示例14: compare
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@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();
}
示例15: compareTo
import com.google.common.collect.ComparisonChain; //導入依賴的package包/類
@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();
}