/** * Implementation of {@link #contains(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 containsNC(final Range<? extends T> range) { return (minValue == null || compareMinTo(range.minValue, range.isMinIncluded ? 0 : +1) <= 0) && (maxValue == null || compareMaxTo(range.maxValue, range.isMaxIncluded ? 0 : -1) >= 0); }
/** * 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; }
/** * Implementation of {@link #union(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<?> unionNC(final Range<? extends T> range) throws IllegalArgumentException { final Range<? extends T> union, 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) { union = min; } else { union = create(min.minValue, min.isMinIncluded, max.maxValue, max.isMaxIncluded); } assert union.contains(min) : min; assert union.contains(max) : max; return union; }
/** * 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; }
} else { final boolean clipMin = compareMinTo(range.minValue, range.isMinIncluded ? 0 : +1) >= 0; final boolean clipMax = compareMaxTo(range.maxValue, range.isMaxIncluded ? 0 : -1) <= 0; if (clipMin) { if (clipMax) {
/** * 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 compareMinTo(range.maxValue, range.isMaxIncluded ? 0 : -1) <= 0 && compareMaxTo(range.minValue, range.isMinIncluded ? 0 : +1) >= 0; }
/** * Implementation of {@link #contains(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 containsNC(final Range<? extends T> range) { return (minValue == null || compareMinTo(range.minValue, range.isMinIncluded ? 0 : +1) <= 0) && (maxValue == null || compareMaxTo(range.maxValue, range.isMaxIncluded ? 0 : -1) >= 0); }
/** * Implementation of {@link #union(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<?> unionNC(final Range<? extends T> range) throws IllegalArgumentException { final Range<? extends T> union, 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) { union = min; } else { union = create(min.minValue, min.isMinIncluded, max.maxValue, max.isMaxIncluded); } assert union.contains(min) : min; assert union.contains(max) : max; return union; }
/** * 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; }
} else { final boolean clipMin = compareMinTo(range.minValue, range.isMinIncluded ? 0 : +1) >= 0; final boolean clipMax = compareMaxTo(range.maxValue, range.isMaxIncluded ? 0 : -1) <= 0; if (clipMin) { if (clipMax) {