org.apache.commons.lang3.BooleanUtils.compare()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.apache.commons.lang3.BooleanUtils.compare()方法的一些代码示例,展示了BooleanUtils.compare()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BooleanUtils.compare()方法的具体详情如下:
包路径:org.apache.commons.lang3.BooleanUtils
类名称:BooleanUtils
方法名:compare

BooleanUtils.compare介绍

[英]Compares two boolean values. This is the same functionality as provided in Java 7.
[中]比较两个布尔值。这与Java7中提供的功能相同。

代码示例

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Compares this mutable to another in ascending order.
 *
 * @param other  the other mutable to compare to, not null
 * @return negative if this is less, zero if equal, positive if greater
 *  where false is less than true
 */
@Override
public int compareTo(final MutableBoolean other) {
  return BooleanUtils.compare(this.value, other.value);
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * <p>This method checks whether the provided array is sorted according to natural ordering
 * ({@code false} before {@code true}).
 *
 * @param array the array to check
 * @return whether the array is sorted according to natural ordering
 * @since 3.4
 */
public static boolean isSorted(final boolean[] array) {
  if (array == null || array.length < 2) {
    return true;
  }
  boolean previous = array[0];
  final int n = array.length;
  for (int i = 1; i < n; i++) {
    final boolean current = array[i];
    if (BooleanUtils.compare(previous, current) > 0) {
      return false;
    }
    previous = current;
  }
  return true;
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testCompare(){
  assertTrue(BooleanUtils.compare(true, false) > 0);
  assertTrue(BooleanUtils.compare(true, true) == 0);
  assertTrue(BooleanUtils.compare(false, false) == 0);
  assertTrue(BooleanUtils.compare(false, true) < 0);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Compares this mutable to another in ascending order.
 *
 * @param other  the other mutable to compare to, not null
 * @return negative if this is less, zero if equal, positive if greater
 *  where false is less than true
 */
@Override
public int compareTo(final MutableBoolean other) {
  return BooleanUtils.compare(this.value, other.value);
}

代码示例来源:origin: de.knightsoft-net/gwt-commons-lang3

/**
 * Compares this mutable to another in ascending order.
 *
 * @param other  the other mutable to compare to, not null
 * @return negative if this is less, zero if equal, positive if greater
 *  where false is less than true
 */
@Override
public int compareTo(final MutableBoolean other) {
  return BooleanUtils.compare(this.value, other.value);
}

代码示例来源:origin: io.virtdata/virtdata-lib-curves4

/**
 * Compares this mutable to another in ascending order.
 *
 * @param other  the other mutable to compare to, not null
 * @return negative if this is less, zero if equal, positive if greater
 *  where false is less than true
 */
@Override
public int compareTo(final MutableBoolean other) {
  return BooleanUtils.compare(this.value, other.value);
}

代码示例来源:origin: io.virtdata/virtdata-lib-curves4

/**
 * <p>This method checks whether the provided array is sorted according to natural ordering
 * ({@code false} before {@code true}).
 *
 * @param array the array to check
 * @return whether the array is sorted according to natural ordering
 * @since 3.4
 */
public static boolean isSorted(final boolean[] array) {
  if (array == null || array.length < 2) {
    return true;
  }
  boolean previous = array[0];
  final int n = array.length;
  for (int i = 1; i < n; i++) {
    final boolean current = array[i];
    if (BooleanUtils.compare(previous, current) > 0) {
      return false;
    }
    previous = current;
  }
  return true;
}

代码示例来源:origin: de.knightsoft-net/gwt-commons-lang3

/**
 * <p>This method checks whether the provided array is sorted according to natural ordering
 * ({@code false} before {@code true}).
 *
 * @param array the array to check
 * @return whether the array is sorted according to natural ordering
 * @since 3.4
 */
public static boolean isSorted(final boolean[] array) {
  if (array == null || array.length < 2) {
    return true;
  }
  boolean previous = array[0];
  final int n = array.length;
  for (int i = 1; i < n; i++) {
    final boolean current = array[i];
    if (BooleanUtils.compare(previous, current) > 0) {
      return false;
    }
    previous = current;
  }
  return true;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * <p>This method checks whether the provided array is sorted according to natural ordering
 * ({@code false} before {@code true}).
 *
 * @param array the array to check
 * @return whether the array is sorted according to natural ordering
 * @since 3.4
 */
public static boolean isSorted(final boolean[] array) {
  if (array == null || array.length < 2) {
    return true;
  }
  boolean previous = array[0];
  final int n = array.length;
  for (int i = 1; i < n; i++) {
    final boolean current = array[i];
    if (BooleanUtils.compare(previous, current) > 0) {
      return false;
    }
    previous = current;
  }
  return true;
}

相关文章