public static boolean safeContains(final Range<Comparable<?>> range, final Comparable<?> endpoint) {
        try {
            return range.contains(endpoint);
        } catch (final ClassCastException ex) {
            Comparable<?> rangeUpperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : null;
            Comparable<?> rangeLowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
            Optional<Class<?>> clazz = getTargetNumericType(Arrays.asList(rangeLowerEndpoint, rangeUpperEndpoint, endpoint));
            if (!clazz.isPresent()) {
                throw ex;
            }
            Range<Comparable<?>> newRange = createTargetNumericTypeRange(range, clazz.get());
            return newRange.contains(parseNumberByClazz(endpoint.toString(), clazz.get()));
        }
    }
@Test
    void assertSafeContainsForBigInteger() {
        Range<Comparable<?>> range = Range.closed(new BigInteger("123"), new BigInteger("1000"));
        assertTrue(SafeNumberOperationUtils.safeContains(range, 510));
    }