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

x33g5p2x  于2022-01-29 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(105)

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

Range.isBefore介绍

[英]Checks whether this range is before the specified element.
[中]检查此范围是否在指定元素之前。

代码示例

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

/**
 * <p>Checks whether this range is completely before the specified range.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to check, null returns false
 * @return true if this range is completely before the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isBeforeRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return isBefore(otherRange.minimum);
}

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

/**
 * <p>Checks where the specified element occurs relative to this range.</p>
 *
 * <p>The API is reminiscent of the Comparable interface returning {@code -1} if
 * the element is before the range, {@code 0} if contained within the range and
 * {@code 1} if the element is after the range. </p>
 *
 * @param element  the element to check for, not null
 * @return -1, 0 or +1 depending on the element's location relative to the range
 */
public int elementCompareTo(final T element) {
  // Comparable API says throw NPE on null
  Validate.notNull(element, "Element is null");
  if (isAfter(element)) {
    return -1;
  } else if (isBefore(element)) {
    return 1;
  } else {
    return 0;
  }
}

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

@Test
public void testIsBefore() {
  assertFalse(intRange.isBefore(null));
  assertFalse(intRange.isBefore(5));
  assertFalse(intRange.isBefore(10));
  assertFalse(intRange.isBefore(15));
  assertFalse(intRange.isBefore(20));
  assertTrue(intRange.isBefore(25));
}

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

/**
 * <p>Checks whether this range is completely before the specified range.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to check, null returns false
 * @return true if this range is completely before the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isBeforeRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return isBefore(otherRange.minimum);
}

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

/**
 * <p>Checks whether this range is completely before the specified range.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to check, null returns false
 * @return true if this range is completely before the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isBeforeRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return isBefore(otherRange.minimum);
}

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

/**
 * <p>Checks whether this range is completely before the specified range.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to check, null returns false
 * @return true if this range is completely before the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isBeforeRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return isBefore(otherRange.minimum);
}

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

/**
 * <p>Checks where the specified element occurs relative to this range.</p>
 *
 * <p>The API is reminiscent of the Comparable interface returning {@code -1} if
 * the element is before the range, {@code 0} if contained within the range and
 * {@code 1} if the element is after the range. </p>
 *
 * @param element  the element to check for, not null
 * @return -1, 0 or +1 depending on the element's location relative to the range
 */
public int elementCompareTo(final T element) {
  // Comparable API says throw NPE on null
  Validate.notNull(element, "Element is null");
  if (isAfter(element)) {
    return -1;
  } else if (isBefore(element)) {
    return 1;
  } else {
    return 0;
  }
}

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

/**
 * <p>Checks where the specified element occurs relative to this range.</p>
 *
 * <p>The API is reminiscent of the Comparable interface returning {@code -1} if
 * the element is before the range, {@code 0} if contained within the range and
 * {@code 1} if the element is after the range. </p>
 *
 * @param element  the element to check for, not null
 * @return -1, 0 or +1 depending on the element's location relative to the range
 */
public int elementCompareTo(final T element) {
  // Comparable API says throw NPE on null
  Validate.notNull(element, "Element is null");
  if (isAfter(element)) {
    return -1;
  } else if (isBefore(element)) {
    return 1;
  } else {
    return 0;
  }
}

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

/**
 * <p>Checks where the specified element occurs relative to this range.</p>
 *
 * <p>The API is reminiscent of the Comparable interface returning {@code -1} if
 * the element is before the range, {@code 0} if contained within the range and
 * {@code 1} if the element is after the range. </p>
 *
 * @param element  the element to check for, not null
 * @return -1, 0 or +1 depending on the element's location relative to the range
 */
public int elementCompareTo(final T element) {
  // Comparable API says throw NPE on null
  Validate.notNull(element, "Element is null");
  if (isAfter(element)) {
    return -1;
  } else if (isBefore(element)) {
    return 1;
  } else {
    return 0;
  }
}

代码示例来源:origin: org.umlg/sqlg-core

private boolean applyRange() {
  if (this.sqlgRangeHolder.getRange().isBefore(this.rangeCount + 1)) {
    throw FastNoSuchElementException.instance();
  }
  if (this.sqlgRangeHolder.getRange().isAfter(this.rangeCount)) {
    this.rangeCount++;
    return true;
  }
  this.rangeCount++;
  return false;
}

代码示例来源:origin: pietermartin/sqlg

private boolean applyRange() {
  if (this.sqlgRangeHolder.getRange().isBefore(this.rangeCount + 1)) {
    throw FastNoSuchElementException.instance();
  }
  if (this.sqlgRangeHolder.getRange().isAfter(this.rangeCount)) {
    this.rangeCount++;
    return true;
  }
  this.rangeCount++;
  return false;
}

代码示例来源:origin: offbynull/portmapper

Range<Long> leaseDurationRange = getLeaseDurationRange();
long leaseDuration;
if (leaseDurationRange.isBefore(lifetime)) {
  leaseDuration = leaseDurationRange.getMaximum();
} else if (leaseDurationRange.isAfter(lifetime)) {

代码示例来源:origin: org.umlg/sqlg-core

private boolean applyRange(Emit<E> emit) {
  if (this.lastReplacedStep.hasRange() && this.lastReplacedStep.applyInStep() && this.lastReplacedStep.getDepth() == emit.getReplacedStepDepth()) {
    if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isBefore(this.rangeCount + 1)) {
      throw FastNoSuchElementException.instance();
    }
    if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isAfter(this.rangeCount)) {
      this.rangeCount++;
      return true;
    }
    this.rangeCount++;
  }
  return false;
}

代码示例来源:origin: pietermartin/sqlg

private boolean applyRange(Emit<E> emit) {
  if (this.lastReplacedStep.hasRange() && this.lastReplacedStep.applyInStep() && this.lastReplacedStep.getDepth() == emit.getReplacedStepDepth()) {
    if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isBefore(this.rangeCount + 1)) {
      throw FastNoSuchElementException.instance();
    }
    if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isAfter(this.rangeCount)) {
      this.rangeCount++;
      return true;
    }
    this.rangeCount++;
  }
  return false;
}

代码示例来源:origin: offbynull/portmapper

Range<Long> leaseDurationRange = getLeaseDurationRange();
long leaseDuration;
if (leaseDurationRange.isBefore(lifetime)) {
  leaseDuration = leaseDurationRange.getMaximum();
} else if (leaseDurationRange.isAfter(lifetime)) {

代码示例来源:origin: offbynull/portmapper

Range<Long> leaseDurationRange = getLeaseDurationRange();
long leaseDuration;
if (leaseDurationRange.isBefore(lifetime)) {
  leaseDuration = leaseDurationRange.getMaximum();
} else if (leaseDurationRange.isAfter(lifetime)) {

代码示例来源:origin: offbynull/portmapper

Range<Long> leaseDurationRange = getLeaseDurationRange();
long leaseDuration;
if (leaseDurationRange.isBefore(lifetime)) {
  leaseDuration = leaseDurationRange.getMaximum();
} else if (leaseDurationRange.isAfter(lifetime)) {

代码示例来源:origin: pietermartin/sqlg

private boolean applyRange(Emit<E> emit) {
  if (this.lastReplacedStep.hasRange() && this.lastReplacedStep.applyInStep() && this.lastReplacedStep.getDepth() == emit.getReplacedStepDepth()) {
    if (this.lastReplacedStep.getSqlgRangeHolder().hasRange()) {
      if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isBefore(this.rangeCount + 1)) {
        throw FastNoSuchElementException.instance();
      }
      if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isAfter(this.rangeCount)) {
        this.rangeCount++;
        return true;
      }
    } else {
      Preconditions.checkState(this.lastReplacedStep.getSqlgRangeHolder().hasSkip(), "If not a range query then it must be a skip.");
      if (this.rangeCount < this.lastReplacedStep.getSqlgRangeHolder().getSkip()) {
        this.rangeCount++;
        return true;
      }
    }
    this.rangeCount++;
  }
  return false;
}

代码示例来源:origin: org.umlg/sqlg-core

private boolean applyRange(Emit<E> emit) {
  if (this.lastReplacedStep.hasRange() && this.lastReplacedStep.applyInStep() && this.lastReplacedStep.getDepth() == emit.getReplacedStepDepth()) {
    if (this.lastReplacedStep.getSqlgRangeHolder().hasRange()) {
      if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isBefore(this.rangeCount + 1)) {
        throw FastNoSuchElementException.instance();
      }
      if (this.lastReplacedStep.getSqlgRangeHolder().getRange().isAfter(this.rangeCount)) {
        this.rangeCount++;
        return true;
      }
    } else {
      Preconditions.checkState(this.lastReplacedStep.getSqlgRangeHolder().hasSkip(), "If not a range query then it must be a skip.");
      if (this.rangeCount < this.lastReplacedStep.getSqlgRangeHolder().getSkip()) {
        this.rangeCount++;
        return true;
      }
    }
    this.rangeCount++;
  }
  return false;
}

相关文章