code: public Range<T> intersectionWith(Range<T> other) {
      if (!this.isOverlappedBy(other)) { throw new IllegalArgumentException(String.format(
          "Cannot calculate intersection with non-overlapping range %s", other)); }
      if (this.equals(other)) { return this; }
      T min = this.comparator.compare(this.min, other.min) < 0 ? other.min : this.min;
      T max = this.comparator.compare(this.max, other.max) < 0 ? this.max : other.max;
      return between(min, max, this.comparator);
    }
docs: Calculate the intersection of {@code this} and an overlapping Range.