@Test public void intersection() throws Exception { Option<Range<Days>> inter = days.intersection(Range.range(Friday, Sunday, enums(Days.class))); assertThat(inter.map(t2-> t2.start).orElse(Days.Monday),equalTo(Friday)); assertThat(inter.map(t2-> t2.end).orElse(Days.Monday),equalTo(Saturday)); }
public Option<Range<T>> intersection(Range<T> toMerge) { T newStart = (T) comp.max(this.start, toMerge.start); T newEnd = (T) comp.min(this.end, toMerge.end); if (comp.isLessThanOrEqual(newStart, newEnd)) return Option.some(range(newStart, newEnd, enm, comp)); return Option.none(); }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Option<Range<T>> intersection(Range<T> toMerge) { T newStart = (T) comp.max(this.start, toMerge.start); T newEnd = (T) comp.min(this.end, toMerge.end); if (comp.isLessThanOrEqual(newStart, newEnd)) return Option.some(range(newStart, newEnd, enm, comp)); return Option.none(); } }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Option<Range<T>> intersection(Range<T> toMerge) { T newStart = (T) comp.max(this.start, toMerge.start); T newEnd = (T) comp.min(this.end, toMerge.end); if (comp.isLessThanOrEqual(newStart, newEnd)) return Option.some(range(newStart, newEnd, enm, comp)); return Option.none(); }  }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Option<Range<T>> intersection(Range<T> toMerge) { T newStart = (T) comp.max(this.start, toMerge.start); T newEnd = (T) comp.min(this.end, toMerge.end); if (comp.isLessThanOrEqual(newStart, newEnd)) return Option.some(range(newStart, newEnd, enm, comp)); return Option.none(); }  static Range<T> range(T start, T end, Enumeration<T> enm, Comparator<? super T> comp); static Range<T> range(T start, T end, Enumeration<T> enm); static Range<Integer> range(int start,int end); Enumeration<T> enumeration(); boolean startsBefore(Range<T> r); boolean endsAfter(Range<T> r); Range<R> map(Function<? super T,? extends R> fn, Enumeration<R> enm, Comparator<? super R> comp); Ordering<? super T> ordering(); Range<T> reverse(); boolean contains(T value); boolean contains(Range<T> compareTo); Tuple2<Range<T>,Option<Range<T>>> plusAll(Range<T> range); Option<Tuple2<Range<T>,Option<Range<T>>>> minusAll(Range<T> range); Option<Range<T>> intersection(Range<T> toMerge); ReactiveSeq<T> stream(); LazySeq<T> lazySeq(); @Override String toString(); String allToString(); @Override Iterator<T> iterator(); }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Option<Range<T>> intersection(Range<T> toMerge) { T newStart = (T) comp.max(this.start, toMerge.start); T newEnd = (T) comp.min(this.end, toMerge.end); if (comp.isLessThanOrEqual(newStart, newEnd)) return Option.some(range(newStart, newEnd, enm, comp)); return Option.none(); }  static Range<T> range(T start, T end, Enumeration<T> enm, Comparator<? super T> comp); static Range<T> range(T start, T end, Enumeration<T> enm); static Range<Integer> range(int start,int end); Enumeration<T> enumeration(); boolean startsBefore(Range<T> r); boolean endsAfter(Range<T> r); Range<R> map(Function<? super T,? extends R> fn, Enumeration<R> enm, Comparator<? super R> comp); Ordering<? super T> ordering(); Range<T> reverse(); boolean contains(T value); boolean contains(Range<T> compareTo); Tuple2<Range<T>,Option<Range<T>>> plusAll(Range<T> range); Option<Tuple2<Range<T>,Option<Range<T>>>> minusAll(Range<T> range); Option<Range<T>> intersection(Range<T> toMerge); ReactiveSeq<T> stream(); LazySeq<T> lazySeq(); @Override String toString(); String allToString(); @Override Iterator<T> iterator(); final T start; final T end; }