public static Range<Comparable<?>> safeIntersection(final Range<Comparable<?>> range, final Range<Comparable<?>> connectedRange) {
        try {
            return range.intersection(connectedRange);
        } catch (final ClassCastException ex) {
            Class<?> clazz = getRangeTargetNumericType(range, connectedRange);
            if (null == clazz) {
                throw ex;
            }
            Range<Comparable<?>> newRange = createTargetNumericTypeRange(range, clazz);
            Range<Comparable<?>> newConnectedRange = createTargetNumericTypeRange(connectedRange, clazz);
            return newRange.intersection(newConnectedRange);
        }
    }
@Test
    void assertSafeIntersectionForFloat() {
        Range<Comparable<?>> range = Range.closed(5.5F, 13.8F);
        Range<Comparable<?>> connectedRange = Range.closed(7.14F, 11.3F);
        Range<Comparable<?>> newRange = SafeNumberOperationUtils.safeIntersection(range, connectedRange);
        assertThat(newRange.lowerEndpoint(), is(7.14F));
        assertThat(newRange.lowerBoundType(), is(BoundType.CLOSED));
        assertThat(newRange.upperEndpoint(), is(11.3F));
        assertThat(newRange.upperBoundType(), is(BoundType.CLOSED));
    }