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

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

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

Range.is介绍

[英]Obtains a range using the specified element as both the minimum and maximum in this range.

The range uses the natural ordering of the elements to determine where values lie in the range.
[中]使用指定的元素作为该范围内的最小值和最大值来获取范围。
范围使用元素的自然顺序来确定值在范围内的位置。

代码示例

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

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testComparableConstructors() {
  final Comparable c = new Comparable() {
    @Override
    public int compareTo(final Object other) {
      return 1;
    }
  };
  final Range r1 = Range.is(c);
  final Range r2 = Range.between(c, c);
  assertTrue(r1.isNaturalOrdering());
  assertTrue(r2.isNaturalOrdering());
}

代码示例来源: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: com.opencsv/opencsv

range = Range.is(Integer.valueOf(r));

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

/**
  * Determine if x is in the set of intervals in O(log*n) time.
  * @param x
  * @return true if in the set of intervals and false otherwise.
  */
 @Override
 public boolean test(T x) {
  long ts = timestampTransformer.apply(x);
  int pos = Collections.binarySearch(intervals, Range.is(ts), INTERVAL_COMPARATOR);
  if(pos < 0) {
   pos = -pos - 1;
  }

  Optional<Range<Long>> right = pos >= 0 && pos < intervals.size()?Optional.of(intervals.get(pos)):Optional.empty();
  Optional<Range<Long>> left = pos - 1 >= 0 && pos - 1 < intervals.size()?Optional.of(intervals.get(pos - 1)):Optional.empty();
  return (right.isPresent()?containsInclusive(right.get(),ts):false) || (left.isPresent()?containsInclusive(left.get(),ts):false);
 }
}

代码示例来源:origin: net.jangaroo/jangaroo-maven-plugin

public void start(String host, int port) throws JettyWrapperException {
 start(host, Range.is(port));
}

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

/**
 * If there are ranges in the list of ranges encompassed by this mapping
 * that stretch beyond the maximum index given, they are shortened to be
 * no longer than the maximum index.
 * Ranges that lie completely beyond the maximum index are shortened to a
 * one-element range consisting of the range's lower boundary. No ranges are
 * under any circumstances removed, as this might compromise checks for
 * required fields.
 * 
 * @param maxIndex The new maximum for ranges
 */
public void attenuateRanges(int maxIndex) {
  ListIterator<Range<Integer>> rangeIterator = ranges.listIterator();
  while(rangeIterator.hasNext()) {
    Range<Integer> r = rangeIterator.next();
    if(r.getMaximum() > maxIndex) {
      if(r.getMinimum() > maxIndex) {
        rangeIterator.set(Range.is(r.getMinimum()));
      }
      else {
        rangeIterator.set(Range.between(r.getMinimum(), maxIndex));
      }
    }
  }
}

代码示例来源:origin: net.jangaroo/jangaroo-maven-plugin

? Range.is(jooUnitJettyPortLowerBound)
    : Range.between(jooUnitJettyPortLowerBound, jooUnitJettyPortUpperBound);
try {

相关文章