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

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

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

Range.getComparator介绍

[英]Gets the comparator being used to determine if objects are within the range.

Natural ordering uses an internal comparator implementation, thus this method never returns null. See #isNaturalOrdering().
[中]获取用于确定对象是否在范围内的比较器。
自然排序使用内部比较器实现,因此该方法永远不会返回null。参见#Is Naturalordering()。

代码示例

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

/**
 * Calculate the intersection of {@code this} and an overlapping Range.
 * @param other overlapping Range
 * @return range representing the intersection of {@code this} and {@code other} ({@code this} if equal)
 * @throws IllegalArgumentException if {@code other} does not overlap {@code this}
 * @since 3.0.1
 */
public Range<T> intersectionWith(final Range<T> other) {
  if (!this.isOverlappedBy(other)) {
    throw new IllegalArgumentException(String.format(
      "Cannot calculate intersection with non-overlapping range %s", other));
  }
  if (this.equals(other)) {
    return this;
  }
  final T min = getComparator().compare(minimum, other.minimum) < 0 ? other.minimum : minimum;
  final T max = getComparator().compare(maximum, other.maximum) < 0 ? maximum : other.maximum;
  return between(min, max, getComparator());
}

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

/**
 * Calculate the intersection of {@code this} and an overlapping Range.
 * @param other overlapping Range
 * @return range representing the intersection of {@code this} and {@code other} ({@code this} if equal)
 * @throws IllegalArgumentException if {@code other} does not overlap {@code this}
 * @since 3.0.1
 */
public Range<T> intersectionWith(final Range<T> other) {
  if (!this.isOverlappedBy(other)) {
    throw new IllegalArgumentException(String.format(
      "Cannot calculate intersection with non-overlapping range %s", other));
  }
  if (this.equals(other)) {
    return this;
  }
  final T min = getComparator().compare(minimum, other.minimum) < 0 ? other.minimum : minimum;
  final T max = getComparator().compare(maximum, other.maximum) < 0 ? maximum : other.maximum;
  return between(min, max, getComparator());
}

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

/**
 * Calculate the intersection of {@code this} and an overlapping Range.
 * @param other overlapping Range
 * @return range representing the intersection of {@code this} and {@code other} ({@code this} if equal)
 * @throws IllegalArgumentException if {@code other} does not overlap {@code this}
 * @since 3.0.1
 */
public Range<T> intersectionWith(final Range<T> other) {
  if (!this.isOverlappedBy(other)) {
    throw new IllegalArgumentException(String.format(
      "Cannot calculate intersection with non-overlapping range %s", other));
  }
  if (this.equals(other)) {
    return this;
  }
  final T min = getComparator().compare(minimum, other.minimum) < 0 ? other.minimum : minimum;
  final T max = getComparator().compare(maximum, other.maximum) < 0 ? maximum : other.maximum;
  return between(min, max, getComparator());
}

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

/**
 * Calculate the intersection of {@code this} and an overlapping Range.
 * @param other overlapping Range
 * @return range representing the intersection of {@code this} and {@code other} ({@code this} if equal)
 * @throws IllegalArgumentException if {@code other} does not overlap {@code this}
 * @since 3.0.1
 */
public Range<T> intersectionWith(final Range<T> other) {
  if (!this.isOverlappedBy(other)) {
    throw new IllegalArgumentException(StringUtils.simpleFormat(
      "Cannot calculate intersection with non-overlapping range %s", other));
  }
  if (this.equals(other)) {
    return this;
  }
  final T min = getComparator().compare(minimum, other.minimum) < 0 ? other.minimum : minimum;
  final T max = getComparator().compare(maximum, other.maximum) < 0 ? maximum : other.maximum;
  return between(min, max, getComparator());
}

相关文章