@Test public void minusAll() throws Exception { Option<Tuple2<Range<Days>, Option<Range<Days>>>> toFriday = days.minusAll(Range.range(Friday, Sunday, enums(Days.class))); assertThat(toFriday.map(t2->t2._1().end).orElse(Monday),equalTo(Friday)); }
public Option<Tuple2<Range<T>,Option<Range<T>>>> minusAll(Range<T> range){ if (comp.isLessThan(end, range.start)) { return Option.some(tuple(this, Option.none())); } if(comp.isGreaterThanOrEqual(start,range.end)){ return Option.some(tuple(this, Option.none())); } if(range.contains(this)){ return Option.none(); } if(comp.isLessThanOrEqual(start,range.start)){ if(comp.isLessThanOrEqual(end,range.end)) return Option.some(tuple(range(start,range.start,enm,comp), Option.none())); else return Option.some(tuple(range(start,range.start,enm,comp), Option.some(range(range.end,end,enm,comp)))); } return Option.some(tuple(range(range.end,end,enm,comp), Option.none())); }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Option<Tuple2<Range<T>,Option<Range<T>>>> minusAll(Range<T> range){ if (comp.isLessThan(end, range.start)) { return Option.some(tuple(this, Option.none())); } if(comp.isGreaterThanOrEqual(start,range.end)){ return Option.some(tuple(this, Option.none())); } if(range.contains(this)){ return Option.none(); } if(comp.isLessThanOrEqual(start,range.start)){ if(comp.isLessThanOrEqual(end,range.end)) return Option.some(tuple(range(start,range.start,enm,comp), Option.none())); else return Option.some(tuple(range(start,range.start,enm,comp), Option.some(range(range.end,end,enm,comp)))); } return Option.some(tuple(range(range.end,end,enm,comp), Option.none())); } }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Option<Tuple2<Range<T>,Option<Range<T>>>> minusAll(Range<T> range){ if (comp.isLessThan(end, range.start)) { return Option.some(tuple(this, Option.none())); } if(comp.isGreaterThanOrEqual(start,range.end)){ return Option.some(tuple(this, Option.none())); } if(range.contains(this)){ return Option.none(); } if(comp.isLessThanOrEqual(start,range.start)){ if(comp.isLessThanOrEqual(end,range.end)) return Option.some(tuple(range(start,range.start,enm,comp), Option.none())); else return Option.some(tuple(range(start,range.start,enm,comp), Option.some(range(range.end,end,enm,comp)))); } return Option.some(tuple(range(range.end,end,enm,comp), Option.none())); }  }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Option<Tuple2<Range<T>,Option<Range<T>>>> minusAll(Range<T> range){ if (comp.isLessThan(end, range.start)) { return Option.some(tuple(this, Option.none())); } if(comp.isGreaterThanOrEqual(start,range.end)){ return Option.some(tuple(this, Option.none())); } if(range.contains(this)){ return Option.none(); } if(comp.isLessThanOrEqual(start,range.start)){ if(comp.isLessThanOrEqual(end,range.end)) return Option.some(tuple(range(start,range.start,enm,comp), Option.none())); else return Option.some(tuple(range(start,range.start,enm,comp), Option.some(range(range.end,end,enm,comp)))); } return Option.some(tuple(range(range.end,end,enm,comp), 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<Tuple2<Range<T>,Option<Range<T>>>> minusAll(Range<T> range){ if (comp.isLessThan(end, range.start)) { return Option.some(tuple(this, Option.none())); } if(comp.isGreaterThanOrEqual(start,range.end)){ return Option.some(tuple(this, Option.none())); } if(range.contains(this)){ return Option.none(); } if(comp.isLessThanOrEqual(start,range.start)){ if(comp.isLessThanOrEqual(end,range.end)) return Option.some(tuple(range(start,range.start,enm,comp), Option.none())); else return Option.some(tuple(range(start,range.start,enm,comp), Option.some(range(range.end,end,enm,comp)))); } return Option.some(tuple(range(range.end,end,enm,comp), 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; }