public String serialize(final Function<T, String> serializer) { return String.format("(%s to %s)", lowerEndpoint().map(e -> serializer.apply(e)).orElse(UNBOUND), upperEndpoint().map(e -> serializer.apply(e)).orElse(UNBOUND)); }
/** * Determines whether the lower endpoint is greater than the upper endpoint. * @return true if the bounds are inverted, false otherwise. */ private boolean hasInvertedBounds() { return isBounded() && lowerEndpoint().get().compareTo(upperEndpoint().get()) > 0; }
/** * Determines whether the range contains no values. A range is empty when it has the form (a, a] or [a, a). * @return true if the range cannot contain any value. */ public boolean isEmpty() { return isBounded() && lowerEndpoint().equals(upperEndpoint()) && lowerBound.get().isExclusive() != upperBound.get().isExclusive(); }