public final boolean isEmpty()

in core/src/main/java/org/apache/commons/functor/range/AbstractRange.java [179:201]


    public final boolean isEmpty() {
        final T leftValue = leftEndpoint.getValue();
        final T rightValue = rightEndpoint.getValue();

        final int cmp = ObjectUtils.compare(leftValue, rightValue);
        final boolean closedLeft = leftEndpoint.getBoundType() == BoundType.CLOSED;
        final boolean closedRight = rightEndpoint.getBoundType() == BoundType.CLOSED;

        if (cmp == 0 && !(closedLeft && closedRight)) {
            return true;
        }

        final T firstValue = closedLeft ? leftValue : nextValue.evaluate(leftValue, step);

        final int cmpFirst = ObjectUtils.compare(firstValue, rightValue);

        if (cmpFirst == 0) {
            return !closedRight;
        }

        final boolean ascending = cmp < 0;
        return ascending ? cmpFirst > 0 : cmpFirst < 0;
    }