/** * Returns the {@linkplain #getMaxDouble() maximum value} with the specified inclusive or exclusive state. * If this range is unbounded, then {@link Double#POSITIVE_INFINITY} is returned. * * @param inclusive {@code true} for the maximum value inclusive, or * {@code false} for the maximum value exclusive. * @return the maximum value, inclusive or exclusive as requested. */ public double getMaxDouble(final boolean inclusive) { double value = getMaxDouble(); if (inclusive != isMaxIncluded()) { value = next(getElementType(), value, !inclusive); } return value; }
/** * Returns the {@linkplain #getMinDouble() minimum value} with the specified inclusive or exclusive state. * If this range is unbounded, then {@link Double#NEGATIVE_INFINITY} is returned. * * @param inclusive {@code true} for the minimum value inclusive, or * {@code false} for the minimum value exclusive. * @return the minimum value, inclusive or exclusive as requested. */ public double getMinDouble(final boolean inclusive) { double value = getMinDouble(); if (inclusive != isMinIncluded()) { value = next(getElementType(), value, inclusive); } return value; }
/** * Returns the {@linkplain #getMaxDouble() maximum value} with the specified inclusive or exclusive state. * If this range is unbounded, then {@link Double#POSITIVE_INFINITY} is returned. * * @param inclusive {@code true} for the maximum value inclusive, or * {@code false} for the maximum value exclusive. * @return the maximum value, inclusive or exclusive as requested. */ public double getMaxDouble(final boolean inclusive) { double value = getMaxDouble(); if (inclusive != isMaxIncluded()) { value = next(getElementType(), value, !inclusive); } return value; }
/** * Returns the {@linkplain #getMinDouble() minimum value} with the specified inclusive or exclusive state. * If this range is unbounded, then {@link Double#NEGATIVE_INFINITY} is returned. * * @param inclusive {@code true} for the minimum value inclusive, or * {@code false} for the minimum value exclusive. * @return the minimum value, inclusive or exclusive as requested. */ public double getMinDouble(final boolean inclusive) { double value = getMinDouble(); if (inclusive != isMinIncluded()) { value = next(getElementType(), value, inclusive); } return value; }
throw new IllegalStateException(Resources.format(Resources.Keys.CanNotEnumerateValuesInRange_1, range)); widestClass = Numbers.widestClass(widestClass, range.getElementType()); ranges[count++] = range; if (range.isMinIncluded()) noDataValues.add(Numbers.cast(minimum, widestClass)); if (range.isMaxIncluded()) noDataValues.add(Numbers.cast(maximum, widestClass)); if (Numbers.isInteger(range.getElementType())) { long value = minimum.longValue() + 1; // If value was inclusive, then it has already been added to the set. long stop = maximum.longValue() - 1;
/** * Tests union and intersection with {@link Double} values. */ @Test public void testWithDoubles() { NumberRange<Double> r1 = NumberRange.create(10.0, true, 20.0, true); NumberRange<Double> r2 = NumberRange.create(15.0, true, 30.0, true); assertEquals(Double.class, r1.getElementType()); assertEquals(Double.class, r2.getElementType()); assertEquals(NumberRange.create(10.0, true, 30.0, true), r1.union(r2)); assertEquals(NumberRange.create(15.0, true, 20.0, true), r1.intersect(r2)); }
final int rangeType = Numbers.getEnumConstant(range.getElementType()); if (rangeType >= dataType && rangeType >= Math.max(Numbers.getEnumConstant(data.getAttributeType(CDM.SCALE_FACTOR)),
/** * Tests union and intersection involving a cast from integer to double values. */ @Test public void testIntegerWithDoubleArguments() { NumberRange<Integer> r1 = NumberRange.create(10, true, 20, true); NumberRange<Double> r2 = NumberRange.create(15.0, true, 30.0, true); assertEquals(Integer.class, r1.getElementType()); assertEquals(Double .class, r2.getElementType()); assertEquals(NumberRange.create(10.0, true, 30.0, true), r1.unionAny(r2)); assertEquals(NumberRange.create(15, true, 20, true), r1.intersectAny(r2)); r2 = NumberRange.create(15.5, true, 30.0, true); assertEquals(NumberRange.create(15.5f, true, 20.0f, true), r1.intersectAny(r2)); }
/** * Tests union and intersection involving a cast from integer to double values. */ @Test public void testDoubleWithIntegerArguments() { NumberRange<Double> r1 = NumberRange.create(10.0, true, 20.0, true); NumberRange<Integer> r2 = NumberRange.create(15, true, 30, true); assertEquals(Double .class, r1.getElementType()); assertEquals(Integer.class, r2.getElementType()); assertEquals(NumberRange.create(10.0, true, 30.0, true), r1.unionAny(r2)); assertEquals(NumberRange.create(15, true, 20, true), r1.intersectAny(r2)); r1 = NumberRange.create(10.0, true, 20.5, true); assertEquals(NumberRange.create(15.0f, true, 20.5f, true), r1.intersectAny(r2)); }
/** * Tests union and intersection with {@link Integer} values. */ @Test public void testWithIntegers() { NumberRange<Integer> r1 = NumberRange.create(10, true, 20, true); NumberRange<Integer> r2 = NumberRange.create(15, true, 30, true); assertTrue (r1.equals(r1)); assertTrue (r2.equals(r2)); assertFalse(r1.equals(r2)); assertEquals(Integer.class, r1.getElementType()); assertEquals(Integer.class, r2.getElementType()); assertEquals(NumberRange.create(10, true, 30, true), r1.union(r2)); assertEquals(NumberRange.create(15, true, 20, true), r1.intersect(r2)); }
if (Numbers.isInteger(samples.getElementType())) {