/** * {@inheritDoc} * If the given range is an instance of {@code MeasurementRange}, then this method converts * the value of the other range to the unit of measurement of this range before to perform * the operation. * * @return {@inheritDoc} * @throws IllegalArgumentException if the given range is an instance of * {@code MeasurementRange} using incommensurable unit of measurement. */ @Override public boolean contains(final Range<? extends E> range) throws IllegalArgumentException { return super.contains(convert(range)); }
/** * {@inheritDoc} * If the given range is an instance of {@code MeasurementRange}, then this method converts * the value of the other range to the unit of measurement of this range before to perform * the operation. * * @return {@inheritDoc} * @throws IllegalArgumentException if the given range is an instance of * {@code MeasurementRange} using incommensurable unit of measurement. */ @Override public boolean contains(final Range<? extends E> range) throws IllegalArgumentException { return super.contains(convert(range)); }
/** * Returns {@code true} if the supplied range is fully contained within this range. * This method converts {@code this} or the given argument to the widest numeric type, * then delegates to {@link #contains(Range)}. * * @param range the range to check for inclusion in this range. * @return {@code true} if the given range is included in this range. * @throws IllegalArgumentException if the given range can not be converted to a valid type * through widening conversion, or if the units of measurement are not convertible. */ @SuppressWarnings({"unchecked","rawtypes"}) public boolean containsAny(final NumberRange<?> range) throws IllegalArgumentException { /* * The type bounds is actually <? extends Number & Comparable> but I'm unable to express * it as local variable as of Java 7. So we have to bypass the compiler check, but those * casts are actually safes. */ final Class type = Numbers.widestClass(elementType, range.elementType); return castTo(type).contains(convertAndCast(range, type)); }
/** * Returns {@code true} if the supplied range is fully contained within this range. * This method converts {@code this} or the given argument to the widest numeric type, * then delegates to {@link #contains(Range)}. * * @param range the range to check for inclusion in this range. * @return {@code true} if the given range is included in this range. * @throws IllegalArgumentException if the given range can not be converted to a valid type * through widening conversion, or if the units of measurement are not convertible. */ @SuppressWarnings({"unchecked","rawtypes"}) public boolean containsAny(final NumberRange<?> range) throws IllegalArgumentException { /* * The type bounds is actually <? extends Number & Comparable> but I'm unable to express * it as local variable as of Java 7. So we have to bypass the compiler check, but those * casts are actually safes. */ final Class type = Numbers.widestClass(elementType, range.elementType); return castTo(type).contains(convertAndCast(range, type)); }