? categories.get(0).getRange().getElementClass() : Double.class; final NumberRange<?> dataRange = configuredRange.castTo(targetType); List<NumberRange<?>> dataRanges = new ArrayList<>(); dataRanges.add(dataRange);
sampleValueRange = nativeCellType.getSampleValueRange().castTo(Double.class);
/** * Returns the union of this range with the given range. Widening conversions will be applied as * needed. */ @Override @SuppressWarnings({"unchecked", "rawtypes"}) public NumberRange<?> union(Range<?> range) { final Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); range = convertAndCast((Range) range, (Class) type); return (NumberRange<?>) castTo((Class) type).unionNC((Range) range); }
/** Returns the range of values that are in this range but not in the given range. */ @Override @SuppressWarnings({"unchecked", "rawtypes"}) public NumberRange<?>[] subtract(Range<?> range) { Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); return (NumberRange[]) castTo((Class) type).subtractNC(convertAndCast((Range) range, (Class) type)); }
/** * Returns {@code true} if the specified value is within this range. The given value must be a * subclass of {@link Number}. * * @throws IllegalArgumentException if the given value is not a subclass of {@link Number}. */ @Override public boolean contains(@SuppressWarnings("rawtypes") Comparable<?> value) throws IllegalArgumentException { if (value == null) { return false; } ensureNumberClass(value.getClass()); /* * Suppress warning because we checked the class in the line just above, so we are safe. * We could have used Class.cast(Object) but we want an IllegalArgumentException with a * localized message. */ Number number = (Number) value; final Class<? extends Number> type = getWidestClass(elementClass, number.getClass()); number = ClassChanger.cast(number, type); /* * The 'type' bounds should actually be <? extends Number & Comparable> since the method * signature expect a Comparable and we have additionnaly casted to a Number. However I * have not found a way to express that safely in a local variable with Java 6. */ @SuppressWarnings({"unchecked", "rawtypes"}) final boolean contains = castTo((Class) type).containsNC((Comparable) number); return contains; }
/** Returns {@code true} if this range intersects the given range. */ @Override @SuppressWarnings({"unchecked", "rawtypes"}) public boolean intersects(Range<?> range) { final Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); /* * The type bounds is actually <? extends Number & Comparable> but I'm unable to express * it it local variable as of Java 6. So we have to bypass the compiler check, but those * casts are actually safes, including Range because getElementClass(range) would have * throw an exception otherwise. */ range = convertAndCast((Range) range, (Class) type); return castTo((Class) type).intersectsNC((Range) range); }
/** Returns {@code true} if the supplied range is fully contained within this range. */ @Override @SuppressWarnings({"unchecked", "rawtypes"}) public boolean contains(Range<?> range) { final Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); /* * The type bounds is actually <? extends Number & Comparable> but I'm unable to express * it it local variable as of Java 6. So we have to bypass the compiler check, but those * casts are actually safes, including Range because getElementClass(range) would have * throw an exception otherwise. */ range = convertAndCast((Range) range, (Class) type); return castTo((Class) type).containsNC((Range) range); }
/** * Returns the intersection of this range with the given range. Widening conversions will be * applied as needed. */ @Override @SuppressWarnings({"unchecked", "rawtypes"}) public NumberRange<?> intersect(Range<?> range) { final Class<? extends Number> rangeType = getElementClass(range); Class<? extends Number> type = getWidestClass(elementClass, rangeType); range = castTo((Class) type).intersectNC(convertAndCast((Range) range, (Class) type)); /* * Use a finer type capable to holds the result (since the intersection * may have reduced the range), but not finer than the finest type of * the ranges used in the intersection calculation. */ type = getFinestClass(elementClass, rangeType); if (range.minValue != null) { type = getWidestClass(type, getFinestClass(((Number) range.minValue).doubleValue())); } if (range.maxValue != null) { type = getWidestClass(type, getFinestClass(((Number) range.maxValue).doubleValue())); } return convertAndCast((Range) range, (Class) type); }
sampleValueRange = NumberRange.create(statsMin, statsMax); Class elementClass = targetCellType.getSampleValueRange().getElementClass(); sampleValueRange = sampleValueRange.castTo(elementClass);
/** * Returns {@code true} if the specified value is within this range. */ public boolean contains(final Number value) { final Class type = ClassChanger.getWidestClass(getElementClass(), value.getClass()); return castTo(type)._contains(ClassChanger.cast(value, type)); }
/** * Returns the union of this range with the given range. * Widening conversions will be applied as needed. */ @Override @SuppressWarnings("unchecked") public NumberRange<?> union(Range<?> range) { final Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); range = convertAndCast((Range) range, (Class) type); return (NumberRange) castTo((Class) type).unionNC((Range)range); }
/** * Returns the range of values that are in this range but not in the given range. */ @Override @SuppressWarnings("unchecked") public NumberRange<?>[] subtract(Range<?> range) { Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); return (NumberRange[]) castTo((Class) type) .subtractNC(convertAndCast((Range) range, (Class) type)); }
/** * Returns {@code true} if this range intersects the given range. */ @Override @SuppressWarnings("unchecked") public boolean intersects(Range<?> range) { final Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); /* * The type bounds is actually <? extends Number & Comparable> but I'm unable to express * it it local variable as of Java 6. So we have to bypass the compiler check, but those * casts are actually safes, including Range because getElementClass(range) would have * throw an exception otherwise. */ range = convertAndCast((Range) range, (Class) type); return castTo((Class) type).intersectsNC((Range)range); }
/** * Returns true if this range intersects the given range. */ //@Override public boolean intersects(final Range range) { final Class type = ClassChanger.getWidestClass(getElementClass(), range.getElementClass()); return castTo(type)._intersects(convertAndCast(range, type)); }
/** * Returns {@code true} if the supplied range is fully contained within this range. */ @Override @SuppressWarnings("unchecked") public boolean contains(Range<?> range) { final Class<? extends Number> type = getWidestClass(elementClass, getElementClass(range)); /* * The type bounds is actually <? extends Number & Comparable> but I'm unable to express * it it local variable as of Java 6. So we have to bypass the compiler check, but those * casts are actually safes, including Range because getElementClass(range) would have * throw an exception otherwise. */ range = convertAndCast((Range) range, (Class) type); return castTo((Class) type).containsNC((Range) range); }
/** * Returns true if the supplied range is fully contained within this range. */ //@Override public boolean contains(final Range range) { final Class type = ClassChanger.getWidestClass(getElementClass(), range.getElementClass()); return castTo(type)._contains(convertAndCast(range, type)); }
/** * Returns the union of this range with the given range. * Widening conversions will be applied as needed. * * @todo The return type will be changed to {@code NumberRange} when J2SE 1.5 * will be available. We should then search for NumberRange.warp(...) in all * client classes; some 'warp' may no longer be needed. */ //@Override public Range union(final Range range) { final Class type = ClassChanger.getWidestClass(getElementClass(), range.getElementClass()); return wrap(castTo(type)._union(convertAndCast(range, type))); }
/** * Returns the range of values that are in this range but not in the given range. * * @todo Consider changing the return type to {@code NumberRange} when we will be allowed * to compile for J2SE 1.5. */ //@Override public Range[] subtract(final Range range) { Class type = ClassChanger.getWidestClass(getElementClass(), range.getElementClass()); final Range[] result = castTo(type)._subtract(convertAndCast(range, type)); if (result != null) { for (int i=0; i<result.length; i++) { result[i] = wrap(result[i]); } } return result; }
/** * Returns the intersection of this range with the given range. Widening * conversions will be applied as needed. */ @Override @SuppressWarnings("unchecked") public NumberRange<?> intersect(Range<?> range) { final Class<? extends Number> rangeType = getElementClass(range); Class<? extends Number> type = getWidestClass(elementClass, rangeType); range = castTo((Class) type).intersectNC(convertAndCast((Range) range, (Class) type)); /* * Use a finer type capable to holds the result (since the intersection * may have reduced the range), but not finer than the finest type of * the ranges used in the intersection calculation. */ type = getFinestClass(elementClass, rangeType); if (range.minValue != null) { type = getWidestClass(type, getFinestClass(((Number) range.minValue).doubleValue())); } if (range.maxValue != null) { type = getWidestClass(type, getFinestClass(((Number) range.maxValue).doubleValue())); } return convertAndCast((Range) range, (Class) type); }
/** * Returns the intersection of this range with the given range. * Widening conversions will be applied as needed. * * @todo The return type will be changed to {@code NumberRange} when J2SE 1.5 * will be available. We should then search for NumberRange.warp(...) in all * client classes; some 'warp' may no longer be needed. */ //@Override public Range intersect(final Range range) { Class type = ClassChanger.getWidestClass(getElementClass(), range.getElementClass()); final Range result = castTo(type)._intersect(convertAndCast(range, type)); /* * Use a finer type capable to holds the result (since the intersection may have * reduced the range), but not finer than the finest type of the ranges used in * the intersection calculation. */ type = ClassChanger.getFinestClass(getElementClass(), range.getElementClass()); return convertAndCast(result, ClassChanger.getWidestClass(type, ClassChanger.getWidestClass( ClassChanger.getFinestClass(((Number)result.getMinValue()).doubleValue()), ClassChanger.getFinestClass(((Number)result.getMaxValue()).doubleValue())))); }