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

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

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

Range.contains介绍

[英]Checks whether the specified element occurs within this range.
[中]检查指定的元素是否出现在此范围内。

代码示例

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

/**
 * <p>Checks whether this range contains all the elements of 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 contains the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean containsRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return contains(otherRange.minimum)
    && contains(otherRange.maximum);
}

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

/**
 * <p>Checks whether this range is overlapped by the specified range.</p>
 *
 * <p>Two ranges overlap if there is at least one element in common.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to test, null returns false
 * @return true if the specified range overlaps with this
 *  range; otherwise, {@code false}
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isOverlappedBy(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return otherRange.contains(minimum)
    || otherRange.contains(maximum)
    || contains(otherRange.minimum);
}

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

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

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

@Test
public void testIsWithCompare() {
  final Comparator<Integer> c = new Comparator<Integer>() {
    @Override
    public int compare(final Integer o1, final Integer o2) {
      return 0; // all integers are equal
    }
  };
  Range<Integer> ri = Range.is(10);
  assertFalse("should not contain null", ri.contains(null));
  assertTrue("should contain 10", ri.contains(10));
  assertFalse("should not contain 11", ri.contains(11));
  ri = Range.is(10, c);
  assertFalse("should not contain null", ri.contains(null));
  assertTrue("should contain 10", ri.contains(10));
  assertTrue("should contain 11", ri.contains(11));
}

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

@Test
public void testRangeOfChars() {
  final Range<Character> chars = Range.between('a', 'z');
  assertTrue(chars.contains('b'));
  assertFalse(chars.contains('B'));
}

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

assertFalse("should not contain null", rb.contains(null));
assertTrue("should contain 10", rb.contains(10));
assertTrue("should contain -10", rb.contains(-10));
assertFalse("should not contain 21", rb.contains(21));
assertFalse("should not contain -11", rb.contains(-11));
rb = Range.between(-10, 20, c);
assertFalse("should not contain null", rb.contains(null));
assertTrue("should contain 10", rb.contains(10));
assertTrue("should contain -10", rb.contains(-10));
assertTrue("should contain 21", rb.contains(21));
assertTrue("should contain -11", rb.contains(-11));
Range<String> rbstr = Range.between("house", "i");
assertFalse("should not contain null", rbstr.contains(null));
assertTrue("should contain house", rbstr.contains("house"));
assertTrue("should contain i", rbstr.contains("i"));
assertFalse("should not contain hose", rbstr.contains("hose"));
assertFalse("should not contain ice", rbstr.contains("ice"));
rbstr = Range.between("house", "i", lengthComp);
assertFalse("should not contain null", rbstr.contains(null));
assertTrue("should contain house", rbstr.contains("house"));
assertTrue("should contain i", rbstr.contains("i"));
assertFalse("should not contain houses", rbstr.contains("houses"));
assertFalse("should not contain ''", rbstr.contains(""));

代码示例来源:origin: apache/metron

private boolean containsInclusive(Range<Long> interval, long ts) {
 return interval.contains(ts) || interval.getMaximum() == ts;
}

代码示例来源:origin: com.github.hazendaz/displaytag

/**
 * Is the current row included in the "to-be-evaluated" range? Called by nested ColumnTags. If <code>false</code>
 * column body is skipped.
 * @return <code>true</code> if the current row must be evaluated because is included in output or because is
 * included in sorting.
 */
public boolean isIncludedRow()
{
  return this.filteredRows.contains(this.rowNumber);
}

代码示例来源:origin: com.danidemi.jlubricant/jlubricant-spring-context

@Override
public boolean contains(Double dateAsDouble) {
  return !range.contains(dateAsDouble);
}

代码示例来源:origin: com.danidemi.jlubricant/jlubricant-spring-context

@Override
public boolean contains(Double dateAsDouble) {
  return range.contains(dateAsDouble);
}

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

/**
 * <p>Checks whether this range contains all the elements of 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 contains the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean containsRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return contains(otherRange.minimum)
    && contains(otherRange.maximum);
}

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

/**
 * <p>Checks whether this range contains all the elements of 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 contains the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean containsRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return contains(otherRange.minimum)
    && contains(otherRange.maximum);
}

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

/**
 * <p>Checks whether this range contains all the elements of 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 contains the specified range
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean containsRange(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return contains(otherRange.minimum)
    && contains(otherRange.maximum);
}

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

/**
 * <p>Checks whether this range is overlapped by the specified range.</p>
 *
 * <p>Two ranges overlap if there is at least one element in common.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to test, null returns false
 * @return true if the specified range overlaps with this
 *  range; otherwise, {@code false}
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isOverlappedBy(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return otherRange.contains(minimum)
    || otherRange.contains(maximum)
    || contains(otherRange.minimum);
}

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

/**
 * <p>Checks whether this range is overlapped by the specified range.</p>
 *
 * <p>Two ranges overlap if there is at least one element in common.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to test, null returns false
 * @return true if the specified range overlaps with this
 *  range; otherwise, {@code false}
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isOverlappedBy(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return otherRange.contains(minimum)
    || otherRange.contains(maximum)
    || contains(otherRange.minimum);
}

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

/**
 * <p>Checks whether this range is overlapped by the specified range.</p>
 *
 * <p>Two ranges overlap if there is at least one element in common.</p>
 *
 * <p>This method may fail if the ranges have two different comparators or element types.</p>
 *
 * @param otherRange  the range to test, null returns false
 * @return true if the specified range overlaps with this
 *  range; otherwise, {@code false}
 * @throws RuntimeException if ranges cannot be compared
 */
public boolean isOverlappedBy(final Range<T> otherRange) {
  if (otherRange == null) {
    return false;
  }
  return otherRange.contains(minimum)
    || otherRange.contains(maximum)
    || contains(otherRange.minimum);
}

代码示例来源:origin: com.opencsv/opencsv

@Override
public boolean contains(Integer key) {
  boolean foundRange = false;
  ListIterator<Range<Integer>> rangeIterator = ranges.listIterator();
  while(rangeIterator.hasNext() && !foundRange) {
    final Range<Integer> range = rangeIterator.next();
    if(range.contains(key)) {
      foundRange = true;
    }
  }
  return foundRange;
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

if (txnRange(currentSegment).contains(committedTxnId.get()) &&
  !txnRange(segment).contains(committedTxnId.get())) {
 throw new AssertionError(
   "Cannot replace segment " +
if (txnRange(currentSegment).contains(highestWrittenTxId)) {
 updateHighestWrittenTxId(segment.getEndTxId());

代码示例来源:origin: Exslims/MercuryTrade

private boolean valueInSoundRange() {
  float value = getValue() / 1000f;
  float threshold = this.descriptor.getSoundThreshold().floatValue();
  return Range.between(threshold - 0.1, threshold + 0.1).contains((double) value);
}

代码示例来源:origin: Wikia/selenium-tests

public void verifyNumberOfTop1kWikisInRange(Range expectedRange) {
 wait.forElementVisible(headerWhereIsMyExtensionPage);
 Log.log("verifyNumberOfTop1kWikisInRange", "Verification of top 1k wikis", true, driver);
 Pattern p = Pattern.compile("\\d+");
 Matcher m = p.matcher(headerWhereIsMyExtensionPage.getText());
 m.find();
 Assertion.assertTrue(
     expectedRange.contains(Integer.parseInt(m.group())),
     String.format("Number of Top 1k Wikis between %s and %s", expectedRange.getMinimum(), expectedRange.getMaximum())
 );
}

相关文章