當前位置: 首頁>>代碼示例>>Java>>正文


Java Booleans.compare方法代碼示例

本文整理匯總了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);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:17,代碼來源:Cut.java

示例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());
}
 
開發者ID:facebook,項目名稱:buck,代碼行數:22,代碼來源:AbstractUnflavoredBuildTarget.java

示例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);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:16,代碼來源:Cut.java

示例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());
  }
}
 
開發者ID:apache,項目名稱:tajo,代碼行數:10,代碼來源:BooleanDatum.java

示例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();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:53,代碼來源:SegmentRecoveryComparator.java

示例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());
}
 
開發者ID:CvvT,項目名稱:andbg,代碼行數:7,代碼來源:BaseBooleanEncodedValue.java

示例7: compareTo

import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
@Override
public int compareTo(Variant o) {
	return Booleans.compare(this.asBoolean(), o.asBoolean());
}
 
開發者ID:OreCruncher,項目名稱:DynamicSurroundings,代碼行數:5,代碼來源:BiomeMatcher.java

示例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());
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:7,代碼來源:BaseBooleanEncodedValue.java

示例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());
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:7,代碼來源:BaseBooleanEncodedValue.java

示例10: compare

import com.google.common.primitives.Booleans; //導入方法依賴的package包/類
@Override
public int compare(VirtualFile file1, VirtualFile file2) {
  return Booleans.compare(hasWebInfParent(file2), hasWebInfParent(file1));
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-intellij,代碼行數:5,代碼來源:DefaultAppEngineAssetProvider.java

示例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));
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:26,代碼來源:DoubleMath.java

示例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));
  }
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:28,代碼來源:DoubleMath.java

示例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));
  }
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:26,代碼來源:DoubleMath.java

示例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));
  }
}
 
開發者ID:google,項目名稱:guava,代碼行數:25,代碼來源:DoubleMath.java

示例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)&lt;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;
}
 
開發者ID:eclipse,項目名稱:xtext-lib,代碼行數:17,代碼來源:BooleanExtensions.java


注:本文中的com.google.common.primitives.Booleans.compare方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。