@Test public void plusAll() throws Exception { Tuple2<Range<Days>,Option<Range<Days>>> toSunday = days.plusAll(Range.range(Saturday, Sunday,enums(Days.class))); Range<Days> rday = toSunday._1(); System.out.println(rday); assertThat(rday.start,equalTo(Days.Tuesday)); assertThat(rday.end,equalTo(Days.Sunday)); }
public Tuple2<Range<T>,Option<Range<T>>> plusAll(Range<T> range){ if(comp.isLessThanOrEqual(start,range.start)){ if(range.contains(end)){ return tuple(range(start,range.end,enm,comp), Option.none()); } if(end.equals(enm.succ(range.end).orElse(null))){ return tuple(range(start,end,enm,comp), Option.none()); } return tuple(this, Option.some(range)); }else{ if(this.contains(range.end)){ return tuple(range(range.start,end,enm,comp), Option.none()); }if(range.end.equals(enm.succ(end).orElse(null))){ return tuple(range(start,range.end,enm,comp), Option.none()); } else{ return tuple(range, Option.some(this)); } } }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Tuple2<Range<T>,Option<Range<T>>> plusAll(Range<T> range){ if(comp.isLessThanOrEqual(start,range.start)){ if(range.contains(end)){ return tuple(range(start,range.end,enm,comp), Option.none()); } if(end.equals(enm.succ(range.end).orElse(null))){ return tuple(range(start,end,enm,comp), Option.none()); } return tuple(this, Option.some(range)); }else{ if(this.contains(range.end)){ return tuple(range(range.start,end,enm,comp), Option.none()); }if(range.end.equals(enm.succ(end).orElse(null))){ return tuple(range(start,range.end,enm,comp), Option.none()); } else{ return tuple(range, Option.some(this)); } } } }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Tuple2<Range<T>,Option<Range<T>>> plusAll(Range<T> range){ if(comp.isLessThanOrEqual(start,range.start)){ if(range.contains(end)){ return tuple(range(start,range.end,enm,comp), Option.none()); } if(end.equals(enm.succ(range.end).orElse(null))){ return tuple(range(start,end,enm,comp), Option.none()); } return tuple(this, Option.some(range)); }else{ if(this.contains(range.end)){ return tuple(range(range.start,end,enm,comp), Option.none()); }if(range.end.equals(enm.succ(end).orElse(null))){ return tuple(range(start,range.end,enm,comp), Option.none()); } else{ return tuple(range, Option.some(this)); } } }  }
Range implements Iterable<T>, Higher<range,T>, Serializable { public Tuple2<Range<T>,Option<Range<T>>> plusAll(Range<T> range){ if(comp.isLessThanOrEqual(start,range.start)){ if(range.contains(end)){ return tuple(range(start,range.end,enm,comp), Option.none()); } if(end.equals(enm.succ(range.end).orElse(null))){ return tuple(range(start,end,enm,comp), Option.none()); } return tuple(this, Option.some(range)); }else{ if(this.contains(range.end)){ return tuple(range(range.start,end,enm,comp), Option.none()); }if(range.end.equals(enm.succ(end).orElse(null))){ return tuple(range(start,range.end,enm,comp), Option.none()); } else{ return tuple(range, Option.some(this)); } } }  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 Tuple2<Range<T>,Option<Range<T>>> plusAll(Range<T> range){ if(comp.isLessThanOrEqual(start,range.start)){ if(range.contains(end)){ return tuple(range(start,range.end,enm,comp), Option.none()); } if(end.equals(enm.succ(range.end).orElse(null))){ return tuple(range(start,end,enm,comp), Option.none()); } return tuple(this, Option.some(range)); }else{ if(this.contains(range.end)){ return tuple(range(range.start,end,enm,comp), Option.none()); }if(range.end.equals(enm.succ(end).orElse(null))){ return tuple(range(start,range.end,enm,comp), Option.none()); } else{ return tuple(range, Option.some(this)); } } }  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; }