upTo<C extends Comparable> static method

Range<C> upTo<C extends Comparable>(
  1. C endpoint,
  2. BoundType boundType
)

Returns a range with no lower bound up to the given endpoint, which may be either inclusive (closed) or exclusive (open).

@since 14.0

Implementation

static Range<C> upTo<C extends Comparable>(C endpoint, BoundType boundType) {
  switch (boundType) {
    case BoundType.open:
      return lessThan(endpoint);
    case BoundType.closed:
      return atMost(endpoint);
    default:
      throw AssertionError();
  }
}