code: private static long end(Range<Long> range) {
          if (range.upperBoundType() == BoundType.OPEN) {
              return DiscreteDomain.longs().previous(range.upperEndpoint());
          } else {
              return range.upperEndpoint();
          }
      }
docs: Get the end of the range. Always use this method to get the end of a
  range because it respects the bound type.
  @param range
  @return End of the range