code: public static <C extends Comparable> ContiguousSet<C> create(
        Range<C> range, DiscreteDomain<C> domain) {
      checkNotNull(range);
      checkNotNull(domain);
      Range<C> effectiveRange = range;
      try {
        if (!range.hasLowerBound()) {
          effectiveRange = effectiveRange.intersection(Range.atLeast(domain.minValue()));
        }
        if (!range.hasUpperBound()) {
          effectiveRange = effectiveRange.intersection(Range.atMost(domain.maxValue()));
        }
      } catch (NoSuchElementException e) {
        throw new IllegalArgumentException(e);
      }
  
      // Per class spec, we are allowed to throw CCE if necessary
      boolean empty =
          effectiveRange.isEmpty()
              || Range.compareOrThrow(
                      range.lowerBound.leastValueAbove(domain),
                      range.upperBound.greatestValueBelow(domain))
                  > 0;
  
      return empty
          ? new EmptyContiguousSet<C>(domain)
          : new RegularContiguousSet<C>(effectiveRange, domain);
    }
docs: Returns a {@code ContiguousSet} containing the same values in the given domain {@linkplain
  Range#contains contained} by the range.
  
  @throws IllegalArgumentException if neither range nor the domain has a lower bound, or if
  neither has an upper bound
  @since 13.0