本文整理汇总了Java中com.google.common.primitives.Booleans.compare方法的典型用法代码示例。如果您正苦于以下问题:Java Booleans.compare方法的具体用法?Java Booleans.compare怎么用?Java Booleans.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.primitives.Booleans
的用法示例。
在下文中一共展示了Booleans.compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo(Cut<C> that) {
if (that == belowAll()) {
return 1;
}
if (that == aboveAll()) {
return -1;
}
int result = Range.compareOrThrow(endpoint, that.endpoint);
if (result != 0) {
return result;
}
// same value. below comes before above
return Booleans.compare(
this instanceof AboveValue, that instanceof AboveValue);
}
示例2: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo(AbstractUnflavoredBuildTarget o) {
if (this == o) {
return 0;
}
int cmp = Booleans.compare(o.getCell().isPresent(), getCell().isPresent());
if (cmp != 0) {
return cmp;
}
if (getCell().isPresent() && o.getCell().isPresent()) {
cmp = StringsUtils.compareStrings(getCell().get(), o.getCell().get());
if (cmp != 0) {
return cmp;
}
}
cmp = StringsUtils.compareStrings(getBaseName(), o.getBaseName());
if (cmp != 0) {
return cmp;
}
return StringsUtils.compareStrings(getShortName(), o.getShortName());
}
示例3: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo(Cut<C> that) {
if (that == belowAll()) {
return 1;
}
if (that == aboveAll()) {
return -1;
}
int result = Range.compareOrThrow(endpoint, that.endpoint);
if (result != 0) {
return result;
}
// same value. below comes before above
return Booleans.compare(this instanceof AboveValue, that instanceof AboveValue);
}
示例4: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo(Datum datum) {
switch (datum.kind()) {
case BOOLEAN:
return Booleans.compare(val, datum.asBool());
default:
throw new InvalidOperationException(datum.type());
}
}
示例5: compare
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compare(
Entry<AsyncLogger, PrepareRecoveryResponseProto> a,
Entry<AsyncLogger, PrepareRecoveryResponseProto> b) {
PrepareRecoveryResponseProto r1 = a.getValue();
PrepareRecoveryResponseProto r2 = b.getValue();
// A response that has data for a segment is always better than one
// that doesn't.
if (r1.hasSegmentState() != r2.hasSegmentState()) {
return Booleans.compare(r1.hasSegmentState(), r2.hasSegmentState());
}
if (!r1.hasSegmentState()) {
// Neither has a segment, so neither can be used for recover.
// Call them equal.
return 0;
}
// They both have a segment.
SegmentStateProto r1Seg = r1.getSegmentState();
SegmentStateProto r2Seg = r2.getSegmentState();
Preconditions.checkArgument(r1Seg.getStartTxId() == r2Seg.getStartTxId(),
"Should only be called with responses for corresponding segments: " +
"%s and %s do not have the same start txid.", r1, r2);
// If one is in-progress but the other is finalized,
// the finalized one is greater.
if (r1Seg.getIsInProgress() != r2Seg.getIsInProgress()) {
return Booleans.compare(!r1Seg.getIsInProgress(), !r2Seg.getIsInProgress());
}
if (!r1Seg.getIsInProgress()) {
// If both are finalized, they should match lengths
if (r1Seg.getEndTxId() != r2Seg.getEndTxId()) {
throw new AssertionError("finalized segs with different lengths: " +
r1 + ", " + r2);
}
return 0;
}
// Both are in-progress.
long r1SeenEpoch = Math.max(r1.getAcceptedInEpoch(), r1.getLastWriterEpoch());
long r2SeenEpoch = Math.max(r2.getAcceptedInEpoch(), r2.getLastWriterEpoch());
return ComparisonChain.start()
.compare(r1SeenEpoch, r2SeenEpoch)
.compare(r1.getSegmentState().getEndTxId(), r2.getSegmentState().getEndTxId())
.result();
}
示例6: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo(@Nonnull EncodedValue o) {
int res = Ints.compare(getValueType(), o.getValueType());
if (res != 0) return res;
return Booleans.compare(getValue(), ((BooleanEncodedValue)o).getValue());
}
示例7: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo(Variant o) {
return Booleans.compare(this.asBoolean(), o.asBoolean());
}
示例8: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo( EncodedValue o) {
int res = Ints.compare(getValueType(), o.getValueType());
if (res != 0) return res;
return Booleans.compare(getValue(), ((BooleanEncodedValue)o).getValue());
}
示例9: compareTo
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compareTo(@Nonnull EncodedValue o) {
int res = Ints.compare(getValueType(), o.getValueType());
if (res != 0) return res;
return Booleans.compare(getValue(), ((BooleanEncodedValue) o).getValue());
}
示例10: compare
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
@Override
public int compare(VirtualFile file1, VirtualFile file2) {
return Booleans.compare(hasWebInfParent(file2), hasWebInfParent(file1));
}
示例11: fuzzyCompare
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
/**
* Compares {@code a} and {@code b} "fuzzily," with a tolerance for nearly-equal values.
*
* <p>This method is equivalent to
* {@code fuzzyEquals(a, b, tolerance) ? 0 : Double.compare(a, b)}. In particular, like
* {@link Double#compare(double, double)}, it treats all NaN values as equal and greater than all
* other values (including {@link Double#POSITIVE_INFINITY}).
*
* <p>This is <em>not</em> a total ordering and is <em>not</em> suitable for use in
* {@link Comparable#compareTo} implementations. In particular, it is not transitive.
*
* @throws IllegalArgumentException if {@code tolerance} is {@code < 0} or NaN
* @since 13.0
*/
public static int fuzzyCompare(double a, double b, double tolerance) {
if (fuzzyEquals(a, b, tolerance)) {
return 0;
} else if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return Booleans.compare(Double.isNaN(a), Double.isNaN(b));
}
}
示例12: fuzzyCompare
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
/**
* Compares {@code a} and {@code b} "fuzzily," with a tolerance for nearly-equal values.
*
* <p>This method is equivalent to
* {@code fuzzyEquals(a, b, tolerance) ? 0 : Double.compare(a, b)}. In particular, like
* {@link Double#compare(double, double)}, it treats all NaN values as equal and greater than all
* other values (including {@link Double#POSITIVE_INFINITY}).
*
* <p>This is <em>not</em> a total ordering and is <em>not</em> suitable for use in
* {@link Comparable#compareTo} implementations. In particular, it is not transitive.
*
* @throws IllegalArgumentException if {@code tolerance} is {@code < 0} or NaN
* @since 13.0
*/
public static int fuzzyCompare(double a, double b, double tolerance) {
if (fuzzyEquals(a, b, tolerance)) {
return 0;
} else if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return Booleans.compare(Double.isNaN(a), Double.isNaN(b));
}
}
示例13: fuzzyCompare
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
/**
* Compares {@code a} and {@code b} "fuzzily," with a tolerance for nearly-equal values.
*
* <p>This method is equivalent to
* {@code fuzzyEquals(a, b, tolerance) ? 0 : Double.compare(a, b)}. In particular, like
* {@link Double#compare(double, double)}, it treats all NaN values as equal and greater than all
* other values (including {@link Double#POSITIVE_INFINITY}).
*
* <p>This is <em>not</em> a total ordering and is <em>not</em> suitable for use in
* {@link Comparable#compareTo} implementations. In particular, it is not transitive.
*
* @throws IllegalArgumentException if {@code tolerance} is {@code < 0} or NaN
* @since 13.0
*/
public static int fuzzyCompare(double a, double b, double tolerance) {
if (fuzzyEquals(a, b, tolerance)) {
return 0;
} else if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return Booleans.compare(Double.isNaN(a), Double.isNaN(b));
}
}
示例14: fuzzyCompare
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
/**
* Compares {@code a} and {@code b} "fuzzily," with a tolerance for nearly-equal values.
*
* <p>This method is equivalent to {@code fuzzyEquals(a, b, tolerance) ? 0 : Double.compare(a,
* b)}. In particular, like {@link Double#compare(double, double)}, it treats all NaN values as
* equal and greater than all other values (including {@link Double#POSITIVE_INFINITY}).
*
* <p>This is <em>not</em> a total ordering and is <em>not</em> suitable for use in {@link
* Comparable#compareTo} implementations. In particular, it is not transitive.
*
* @throws IllegalArgumentException if {@code tolerance} is {@code < 0} or NaN
* @since 13.0
*/
public static int fuzzyCompare(double a, double b, double tolerance) {
if (fuzzyEquals(a, b, tolerance)) {
return 0;
} else if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return Booleans.compare(Double.isNaN(a), Double.isNaN(b));
}
}
示例15: operator_lessThan
import com.google.common.primitives.Booleans; //导入方法依赖的package包/类
/**
* The binary <code>lessThan</code> operator for boolean values.
* {@code false} is considered less than {@code true}.
*
* @see Boolean#compareTo(Boolean)
* @see Booleans#compare(boolean, boolean)
* @param a a boolean.
* @param b another boolean.
* @return <code>Booleans.compare(a, b)<0</code>
* @since 2.4
*/
@Pure
@Inline(value = "($3.compare($1, $2) < 0)", imported = Booleans.class)
public static boolean operator_lessThan(boolean a, boolean b) {
return Booleans.compare(a, b) < 0;
}