org.geotools.util.Range.isEmpty()方法的使用及代码示例

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

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

Range.isEmpty介绍

[英]Returns true if this range is empty. A range is empty if the #getMinValue is smaller than the #getMaxValue, or if they are equals while at least one of them is exclusive.
[中]如果此范围为空,则返回true。如果#getMinValue小于#getMaxValue,或者如果它们相等,但至少有一个是独占的,则范围为空。

代码示例

代码示例来源:origin: geotools/geotools

/**
 * Implementation of {@link #intersects(Range)} to be invoked directly by subclasses. "NC"
 * stands for "No Cast" - this method do not try to cast the value to a compatible type.
 */
final boolean intersectsNC(final Range<? extends T> range) {
  return !isEmpty()
      && !range.isEmpty()
      && compareMinTo(range.maxValue, range.isMaxIncluded ? 0 : -1) <= 0
      && compareMaxTo(range.minValue, range.isMinIncluded ? 0 : +1) >= 0;
}

代码示例来源:origin: geotools/geotools

/** Returns a string representation of this range. */
  @Override
  public String toString() {
    if (isEmpty()) {
      return "[]";
    }
    final StringBuilder buffer = new StringBuilder();
    buffer.append(isMinIncluded ? '[' : '(');
    if (minValue == null) {
      buffer.append("-\u221E"); // Infinity
    } else {
      buffer.append(minValue);
    }
    buffer.append(", ");
    if (maxValue == null) {
      buffer.append('\u221E'); // Infinity
    } else {
      buffer.append(maxValue);
    }
    buffer.append(isMaxIncluded ? ']' : ')');
    final Unit<?> units = getUnits();
    if (units != null) {
      buffer.append(' ').append(units);
    }
    return buffer.toString();
  }
}

代码示例来源:origin: geotools/geotools

public void removeRange(Range<T> range) {
  List<Range<T>> overlapping = getOverlappingRanges(range);
  if (overlapping != null) {
    ranges.remove(overlapping);
    List<Range<?>> removed = new ArrayList<>();
    for (Range<T> r : overlapping) {
      Range<?>[] difference = r.subtract(range);
      for (Range<?> d : difference) {
        if (!d.isEmpty()) {
          removed.add(d);
        }
      }
    }
    for (Range<?> r : removed) {
      ranges.add((Range<T>) r);
    }
  }
}

代码示例来源:origin: geotools/geotools

/**
 * Compares this range with the given object for equality.
 *
 * @param object The object to compare with this range for equality.
 * @return {@code true} if the given object is equals to this range.
 */
@Override
public boolean equals(final Object object) {
  if (object == this) {
    return true;
  }
  if (object != null && object.getClass().equals(getClass())) {
    final Range<?> other = (Range<?>) object;
    if (Utilities.equals(elementClass, other.elementClass)) {
      if (isEmpty()) {
        return other.isEmpty();
      }
      return Utilities.equals(minValue, other.minValue)
          && Utilities.equals(maxValue, other.maxValue)
          && isMinIncluded == other.isMinIncluded
          && isMaxIncluded == other.isMaxIncluded;
    }
  }
  return false;
}

代码示例来源:origin: geotools/geotools

public void addRange(Range<T> range) {
  if (range.isEmpty()) {
    return;
  }
  List<Range<T>> overlapping = getOverlappingRanges(range);
  if (overlapping != null && !overlapping.isEmpty()) {
    ranges.removeAll(overlapping);
    Range combined = range;
    for (Range r : overlapping) {
      combined = combined.union(r);
    }
    ranges.add(combined);
  } else {
    ranges.add(range);
  }
}

代码示例来源:origin: geotools/geotools

/** Returns a hash code value for this range. */
@Override
public int hashCode() {
  int result = (int) serialVersionUID;
  if (!isEmpty()) {
    result += elementClass.hashCode();
    result = Utilities.hash(isMaxIncluded, result);
    result = Utilities.hash(isMinIncluded, result);
    result = Utilities.hash(maxValue, result);
    result = Utilities.hash(minValue, result);
  }
  return result;
}

代码示例来源:origin: geotools/geotools

/**
 * Implementation of {@link #intersect(Range)} to be invoked directly by subclasses. "NC" stands
 * for "No Cast" - this method do not try to cast the value to a compatible type.
 */
final Range<? extends T> intersectNC(final Range<? extends T> range)
    throws IllegalArgumentException {
  final Range<? extends T> intersect, min, max;
  min = compareMinTo(range.minValue, range.isMinIncluded ? 0 : +1) < 0 ? range : this;
  max = compareMaxTo(range.maxValue, range.isMaxIncluded ? 0 : -1) > 0 ? range : this;
  if (min == max) {
    intersect = min;
  } else {
    intersect = create(min.minValue, min.isMinIncluded, max.maxValue, max.isMaxIncluded);
  }
  assert intersect.isEmpty() == !intersects(range) : intersect;
  return intersect;
}

代码示例来源:origin: org.geotools/gt-css

public static Selector combineAnd(List<ScaleRange> selectors, Object ctx) {
  if (selectors.size() == 1) {
    return selectors.get(0);
  }
  Range<?> range = selectors.get(0).range;
  for (ScaleRange selector : selectors) {
    range = range.intersect(selector.range);
    if (range.isEmpty()) {
      return REJECT;
    }
  }
  return new ScaleRange((Range<Double>) range);
}

代码示例来源:origin: org.geotools/gt-metadata

/**
   * Returns a string representation of this range.
   */
  @Override
  public String toString() {
    if (isEmpty()) {
      return "[]";
    }
    final StringBuilder buffer = new StringBuilder();
    buffer.append(isMinIncluded ? '[' : '(');
    if (minValue == null) {
      buffer.append("-\u221E"); // Infinity
    } else {
      buffer.append(minValue);
    }
    buffer.append(", ");
    if (maxValue == null) {
      buffer.append('\u221E'); // Infinity
    } else {
      buffer.append(maxValue);
    }
    buffer.append(isMaxIncluded ? ']' : ')');
    final Unit<?> units = getUnits();
    if (units != null) {
      buffer.append(' ').append(units);
    }
    return buffer.toString();
  }
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Compares this range with the given object for equality.
 *
 * @param  object The object to compare with this range for equality.
 * @return {@code true} if the given object is equals to this range.
 */
@Override
public boolean equals(final Object object) {
  if (object == this) {
    return true;
  }
  if (object != null && object.getClass().equals(getClass())) {
    final Range<?> other = (Range) object;
    if (Utilities.equals(elementClass, other.elementClass)) {
      if (isEmpty()) {
        return other.isEmpty();
      }
      return Utilities.equals(minValue, other.minValue) &&
          Utilities.equals(maxValue, other.maxValue) &&
          isMinIncluded == other.isMinIncluded &&
          isMaxIncluded == other.isMaxIncluded;
    }
  }
  return false;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Returns a hash code value for this range.
 */
@Override
public int hashCode() {
  int result = (int) serialVersionUID;
  if (!isEmpty()) {
    result += elementClass.hashCode();
    result = Utilities.hash(isMaxIncluded, result);
    result = Utilities.hash(isMinIncluded, result);
    result = Utilities.hash(maxValue, result);
    result = Utilities.hash(minValue, result);
  }
  return result;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Implementation of {@link #intersect(Range)} to be invoked directly by subclasses.
 * "NC" stands for "No Cast" - this method do not try to cast the value to a compatible type.
 */
final Range<? extends T> intersectNC(final Range<? extends T> range)
    throws IllegalArgumentException
{
  final Range<? extends T> intersect, min, max;
  min = compareMinTo(range.minValue, range.isMinIncluded ? 0 : +1) < 0 ? range : this;
  max = compareMaxTo(range.maxValue, range.isMaxIncluded ? 0 : -1) > 0 ? range : this;
  if (min == max) {
    intersect = min;
  } else {
    intersect = create(min.minValue, min.isMinIncluded, max.maxValue, max.isMaxIncluded);
  }
  assert intersect.isEmpty() == !intersects(range) : intersect;
  return intersect;
}

代码示例来源:origin: org.geotools/gt-css

if (scaleRange != null && scaleRange.isEmpty()) {
  return;

相关文章