当前位置: 首页>>代码示例>>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;未经允许,请勿转载。