Java Code Examples for org.apache.commons.lang3.Range#between()

The following examples show how to use org.apache.commons.lang3.Range#between() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LookupTableTransitionTest.java    From synthea with Apache License 2.0 7 votes vote down vote up
@Test
public void keyTestWithAgesMatch() {
  DirectTransition test = new DirectTransition("test");

  List<String> attributes = new ArrayList<String>();
  attributes.add("foo");
  attributes.add("bar");
  Integer age = 20;
  LookupTableKey silver = test.new LookupTableKey(attributes, age, null);

  List<String> others = new ArrayList<String>();
  others.add("foo");
  others.add("bar");
  Range<Integer> range = Range.between(0, 30);
  LookupTableKey gold = test.new LookupTableKey(others, range, null);

  Assert.assertEquals(silver, gold);
  Assert.assertEquals(gold, silver);

  Set<LookupTableKey> set = new HashSet<LookupTableKey>();
  set.add(gold);
  Assert.assertTrue(set.contains(silver));
}
 
Example 2
Source File: TimeFrame.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
/**
 * Check if a movement with the provided runtime is possible for this
 * AttackFitter
 *
 * @param pRuntime Runtime to check
 * @param pVillage Village for which the runtime is valid
 * @return boolean TRUE=Runtime might be fitted if not all send times are
 * already used
 */
public boolean isMovementPossible(long pRuntime) {
  if (startRanges == null) {
    startRanges = startTimespansToRanges();
  }
  if (arriveRanges == null) {
    arriveRanges = arriveTimespansToRanges();
  }

  for (Range<Long> currentStartRange : startRanges) {
    Range<Long> arriveRangeForStartRange = Range.between(currentStartRange.getMinimum() + pRuntime, currentStartRange.getMaximum() + pRuntime);
    for (Range<Long> currentArriveRange : arriveRanges) {
      if (currentArriveRange.isOverlappedBy(arriveRangeForStartRange)) {
        //movement with 'pRuntime' starting in 'currentStartRange' will arrive withing 'currentArriveRange'
        return true;
      }
    }
  }
  //no overlapping range was found
  return false;
}
 
Example 3
Source File: LookupTableTransitionTest.java    From synthea with Apache License 2.0 6 votes vote down vote up
@Test
public void keyTestWithAgesMatchHigh() {
  DirectTransition test = new DirectTransition("test");

  List<String> attributes = new ArrayList<String>();
  attributes.add("foo");
  attributes.add("bar");
  Integer age = 30;
  LookupTableKey silver = test.new LookupTableKey(attributes, age, null);

  List<String> others = new ArrayList<String>();
  others.add("foo");
  others.add("bar");
  Range<Integer> range = Range.between(0, 30);
  LookupTableKey gold = test.new LookupTableKey(others, range, null);

  Assert.assertEquals(silver, gold);
  Assert.assertEquals(gold, silver);

  Set<LookupTableKey> set = new HashSet<LookupTableKey>();
  set.add(gold);
  Assert.assertTrue(set.contains(silver));
}
 
Example 4
Source File: LookupTableTransitionTest.java    From synthea with Apache License 2.0 6 votes vote down vote up
@Test
public void keyTestWithAgesMatchLow() {
  DirectTransition test = new DirectTransition("test");

  List<String> attributes = new ArrayList<String>();
  attributes.add("foo");
  attributes.add("bar");
  Integer age = 0;
  LookupTableKey silver = test.new LookupTableKey(attributes, age, null);

  List<String> others = new ArrayList<String>();
  others.add("foo");
  others.add("bar");
  Range<Integer> range = Range.between(0, 30);
  LookupTableKey gold = test.new LookupTableKey(others, range, null);

  Assert.assertEquals(silver, gold);
  Assert.assertEquals(gold, silver);

  Set<LookupTableKey> set = new HashSet<LookupTableKey>();
  set.add(gold);
  Assert.assertTrue(set.contains(silver));
}
 
Example 5
Source File: AttackTimePanel.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
/**
 * Get the currently set up arrive span
 *
 * @return TimeSpan The arrive span
 */
private TimeSpan getArriveSpan() {
    TimeSpan arrive = null;
    Range<Long> range = Range.between(Math.round(jSendTimeFrame.getMinimumColoredValue()) * DateUtils.MILLIS_PER_HOUR,
            Math.round(jSendTimeFrame.getMaximumColoredValue()) * DateUtils.MILLIS_PER_HOUR);
    if (Objects.equals(range.getMinimum(), range.getMaximum()) && !jExactTimeButton.isSelected()) {
        return null;
    }
    
    if (jAlwaysButton.isSelected()) {
        arrive = new TimeSpan(range, true);
    } else if (jDayButton.isSelected()) {
        range = Range.between(dateTimeField.getSelectedDate().getTime() + range.getMinimum(),
                dateTimeField.getSelectedDate().getTime() + range.getMaximum());
        arrive = new TimeSpan(range, false);
    } else if (jExactTimeButton.isSelected()) {
        arrive = new TimeSpan(dateTimeField.getSelectedDate());
    }
    if (arrive != null) {
        arrive.setDirection(TimeSpan.DIRECTION.ARRIVE);
    }
    
    return arrive;
}
 
Example 6
Source File: LookupTableTransitionTest.java    From synthea with Apache License 2.0 6 votes vote down vote up
@Test
public void keyTestWithAgesNoMatchAge() {
  DirectTransition test = new DirectTransition("test");

  List<String> attributes = new ArrayList<String>();
  attributes.add("foo");
  attributes.add("bar");
  Integer age = 40;
  LookupTableKey silver = test.new LookupTableKey(attributes, age, null);

  List<String> others = new ArrayList<String>();
  others.add("foo");
  others.add("bar");
  Range<Integer> range = Range.between(0, 30);
  LookupTableKey gold = test.new LookupTableKey(others, range, null);

  Assert.assertNotEquals(silver, gold);
  Assert.assertNotEquals(gold, silver);

  Set<LookupTableKey> set = new HashSet<LookupTableKey>();
  set.add(gold);
  Assert.assertFalse(set.contains(silver));
}
 
Example 7
Source File: BasicOrderedConstraintQuery.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
public void fromBinary(final byte[] bytes) {
  final ByteBuffer buf = ByteBuffer.wrap(bytes);
  final int numRanges = VarintUtils.readUnsignedInt(buf);
  ByteArrayUtils.verifyBufferSize(buf, numRanges);
  rangesPerDimension = new Range[numRanges];
  final int indexNameBinaryLength = VarintUtils.readUnsignedInt(buf);
  for (int i = 0; i < rangesPerDimension.length; i++) {
    rangesPerDimension[i] = Range.between(buf.getDouble(), buf.getDouble());
  }
  if (indexNameBinaryLength > 0) {
    final byte[] indexNameBinary = ByteArrayUtils.safeRead(buf, indexNameBinaryLength);
    indexName = StringUtils.stringFromBinary(indexNameBinary);
  } else {
    indexName = null;
  }
}
 
Example 8
Source File: AttackTimePanel.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
/**
 * Get the currently set up send span
 *
 * @return TimeSpan The send span
 */
private TimeSpan getSendSpan() {
    TimeSpan start = null;
    Range<Long> range = Range.between(Math.round(jSendTimeFrame.getMinimumColoredValue()) * DateUtils.MILLIS_PER_HOUR,
            Math.round(jSendTimeFrame.getMaximumColoredValue()) * DateUtils.MILLIS_PER_HOUR);
    if (Objects.equals(range.getMinimum(), range.getMaximum()) && !jExactTimeButton.isSelected()) {
        return null;
    }
    
    if (jAlwaysButton.isSelected()) {
        start = new TimeSpan(range, true);
    } else if (jDayButton.isSelected()) {
        range = Range.between(dateTimeField.getSelectedDate().getTime() + range.getMinimum(),
                dateTimeField.getSelectedDate().getTime() + range.getMaximum());
        start = new TimeSpan(range, false);
    } else if (jExactTimeButton.isSelected()) {
        start = new TimeSpan(dateTimeField.getSelectedDate());
    }
    if (start != null) {
        start.setDirection(TimeSpan.DIRECTION.SEND);
    }

    return start;
}
 
Example 9
Source File: DSWorkbenchFarmManager.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
public Range<Integer> getFarmRange(FARM_CONFIGURATION pConfig) {
    if (pConfig == null) {
        pConfig = FARM_CONFIGURATION.C;
    }
    switch (pConfig) {
        case A:
        return Range.between(UIHelper.parseIntFromField(jMinFarmRuntimeA, 0),
                UIHelper.parseIntFromField(jMaxFarmRuntimeA, 60));
        case B:
        return Range.between(UIHelper.parseIntFromField(jMinFarmRuntimeB, 0),
                UIHelper.parseIntFromField(jMaxFarmRuntimeB, 60));
    case K:
        return Range.between(UIHelper.parseIntFromField(jMinFarmRuntimeK, 0),
                UIHelper.parseIntFromField(jMaxFarmRuntimeK, 60));
        default:
        return Range.between(UIHelper.parseIntFromField(jMinFarmRuntimeC, 0),
                UIHelper.parseIntFromField(jMaxFarmRuntimeC, 60));
    }
}
 
Example 10
Source File: TimeSpan.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
public static TimeSpan fromPropertyString(String pString) {
  String[] split = pString.split(",");
  try {
    long start = Long.parseLong(split[0]);
    long end = Long.parseLong(split[1]);
    boolean daily = Boolean.parseBoolean(split[2]);
    int dir = Integer.parseInt(split[3]);
    TimeSpan t = new TimeSpan(Range.between(start, end), daily);
    switch (dir) {
      case 0:
        t.setDirection(DIRECTION.SEND);
        break;
      case 1:
        t.setDirection(DIRECTION.ARRIVE);
        break;
    }
    return t;
  } catch (Exception ignored) {
  }
  return null;
}
 
Example 11
Source File: Window.java    From metron with Apache License 2.0 5 votes vote down vote up
/**
 * Compute the set of sorted (oldest to newest) window intervals relative to the passed timestamp
 * given inclusion and exclusion predicates.
 *
 * @param now
 * @return intervals returns a set of sorted (oldest to newest) window intervals relative to the
 * passed timestamp given inclusion and exclusion predicates.
 */
public List<Range<Long>> toIntervals(long now) {
  List<Range<Long>> intervals = new ArrayList<>();
  long startMillis = getStartMillis(now);
  long endMillis = getEndMillis(now);
  Iterable<Predicate<Long>> includes = getIncludes(now);
  Iterable<Predicate<Long>> excludes = getExcludes(now);
  //if we don't have a skip distance, then we just skip past everything to make the window dense
  long skipDistance = getSkipDistance().orElse(Long.MAX_VALUE);
  //if we don't have a window width, then we want the window to be completely dense.
  Optional<Long> binWidthOpt = getBinWidth();
  long binWidth = binWidthOpt.isPresent()?binWidthOpt.get():endMillis-startMillis;

  for(long left = startMillis;left >= 0 && left + binWidth <= endMillis;left += skipDistance) {
    Range<Long> interval = Range.between(left, left + binWidth);
    boolean include = includes.iterator().hasNext()?false:true;
    for(Predicate<Long> inclusionPredicate : includes) {
      include |= inclusionPredicate.test(left);
    }
    if(include) {
      for(Predicate<Long> exclusionPredicate : excludes) {
        include &= !exclusionPredicate.test(left);
      }
    }
    if(include) {
      intervals.add(interval);
    }
  }
  return intervals;
}
 
Example 12
Source File: TimeSpan.java    From dsworkbench with Apache License 2.0 5 votes vote down vote up
public boolean intersectsWithNightBonus() {
  if (!ServerSettings.getSingleton().isNightBonusActive()) {
      return false;
  }
  TimeSpan nightBonusSpan = new TimeSpan(
          Range.between(ServerSettings.getSingleton().getNightBonusStartHour() * DateUtils.MILLIS_PER_HOUR,
          ServerSettings.getSingleton().getNightBonusEndHour() * DateUtils.MILLIS_PER_HOUR), true);
  return nightBonusSpan.intersects(this);
}
 
Example 13
Source File: LookupTableTransitionTest.java    From synthea with Apache License 2.0 5 votes vote down vote up
@Test
public void keyTestCorrectMatch() {
  DirectTransition test = new DirectTransition("test");

  List<String> attributes = new ArrayList<String>();
  attributes.add("foo");
  attributes.add("bar");
  Integer age = 20;
  LookupTableKey yellow = test.new LookupTableKey(attributes, age, null);
  age = 50;
  LookupTableKey grey = test.new LookupTableKey(attributes, age, null);

  List<String> others = new ArrayList<String>();
  others.add("foo");
  others.add("bar");
  Range<Integer> range = Range.between(0, 30);
  LookupTableKey gold = test.new LookupTableKey(others, range, null);

  Range<Integer> anotherRange = Range.between(31, 60);
  LookupTableKey platinum = test.new LookupTableKey(others, anotherRange, null);

  Assert.assertEquals(yellow, gold);
  Assert.assertEquals(gold, yellow);
  Assert.assertEquals(grey, platinum);
  Assert.assertEquals(platinum, grey);

  Assert.assertNotEquals(grey, gold);
  Assert.assertNotEquals(yellow, platinum);
  Assert.assertNotEquals(gold, platinum);
  Assert.assertNotEquals(yellow, grey);

  Map<LookupTableKey, String> map = new HashMap<LookupTableKey, String>();
  map.put(gold, "gold");
  map.put(platinum, "platinum");
  Assert.assertTrue(map.containsKey(yellow));
  Assert.assertEquals(map.get(yellow), "gold");
  Assert.assertTrue(map.containsKey(grey));
  Assert.assertEquals(map.get(grey), "platinum");
}
 
Example 14
Source File: PasswordCheck.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Method for checking the length of a password is within the bounds
 * 
 * @param passwd - string to check length of
 * @param min	- minimum length
 * @param max	- maximum length (must be >= min)
 * @return
 */
public static boolean isAcceptableLength(String passwd, int min, int max) {
	
	//null
	if (StringUtils.isBlank(passwd))
	{
		return false;
	}
	
	//check bounds
	if(min > max){
		log.error("Invalid bounds supplied, min (" + min + ") is greater than max (" + max + ")");
	}
	
	// LENGTH
	int length = passwd.length();
	
	//check range
	Range<Integer> range = Range.between(min, max);
	
	if(range.contains(length))
	{
		log.debug("Range ok");
		return true;
	}
	log.debug("Range bad; min=" + min + ", max=" + max + ", length=" + length);
	return false;
}
 
Example 15
Source File: TimeSpan.java    From dsworkbench with Apache License 2.0 4 votes vote down vote up
public boolean intersects(TimeSpan pSpan) {
  if (!this.getDirection().equals(pSpan.getDirection())) {
    //different directions
    return false;
  }
  
  //one of the spans uses manual Time (new intersect)
  Range<Long> thisSpan = this.getSpan();
  Range<Long> theOtherSpan = pSpan.getSpan();
  
  if(this.isValidAtEveryDay() || pSpan.isValidAtEveryDay()) {
      if(this.isValidAtSpecificDay() || pSpan.isValidAtSpecificDay()) {
        //remove day Information
        Long thisStart = DateUtils.getFragmentInMilliseconds(new Date(thisSpan.getMinimum()), Calendar.DATE);
        Long thisEnd = DateUtils.getFragmentInMilliseconds(new Date(thisSpan.getMaximum()), Calendar.DATE);
        thisSpan = Range.between(thisStart, thisEnd);
        
        Long otherStart = DateUtils.getFragmentInMilliseconds(new Date(theOtherSpan.getMinimum()), Calendar.DATE);
        Long otherEnd = DateUtils.getFragmentInMilliseconds(new Date(theOtherSpan.getMaximum()), Calendar.DATE);
        
        theOtherSpan = Range.between(otherStart, otherEnd);
        
        return thisSpan.isOverlappedBy(theOtherSpan);
      } else if(this.isValidAtEveryDay() && pSpan.isValidAtEveryDay()) {
        //both valid at every Day - just compare spans
        return thisSpan.isOverlappedBy(theOtherSpan);
      } else {
          //one span is for everyDay the other is over multiple Days
          //manual intersect
          Range<Long> always;
          Range<Long> manual;
          if(this.isValidAtEveryDay()) {
              always = thisSpan;
              manual = theOtherSpan;
          } else {
              always = theOtherSpan;
              manual = thisSpan;
          }
          
          long manualDate = DateUtils.truncate(new Date(manual.getMinimum()), Calendar.DATE).getTime();
          long manualStart = manual.getMinimum() - manualDate;
          long manualEnd = manual.getMaximum() - manualDate;
          
          if(manualEnd - manualStart > DateUtils.MILLIS_PER_DAY) {
              //must intersect somehow because span is longer than 1 Day
              return true;
          }
          //direct intersection
          manual = Range.between(manualStart, manualEnd);
          if(always.isOverlappedBy(manual)) return true;
          
          //should not be possible, because it should be handeld by isValidAtSpecificDay
          if(manualEnd <= DateUtils.MILLIS_PER_DAY) return false;
          
          //maybe intersection at next day
          manual = Range.between(new Long(0), manualEnd - DateUtils.MILLIS_PER_DAY);
          return always.isOverlappedBy(manual);
      }
  }
  
  return thisSpan.isOverlappedBy(theOtherSpan);
}
 
Example 16
Source File: TimeSpan.java    From dsworkbench with Apache License 2.0 4 votes vote down vote up
public TimeSpan(Date pExactDate) { //exact Time
  this(Range.between(pExactDate.getTime(), pExactDate.getTime()), false);
}
 
Example 17
Source File: WrappedGorillaCompressor.java    From timely with Apache License 2.0 4 votes vote down vote up
public boolean inRange(long begin, long end) {
    Range<Long> requestedRange = Range.between(begin, end);
    Range<Long> compressorRange = Range.between(oldestTimestamp, newestTimestamp);
    return compressorRange.isOverlappedBy(requestedRange);
}
 
Example 18
Source File: Application.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
@Override
public void populateDAG(DAG dag, Configuration conf)
{
  String lPhoneRange = conf.get(PHONE_RANGE_PROP, null);
  if (lPhoneRange != null) {
    String[] tokens = lPhoneRange.split("-");
    if (tokens.length != 2) {
      throw new IllegalArgumentException("Invalid range: " + lPhoneRange);
    }
    this.phoneRange = Range.between(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
  }
  LOG.debug("Phone range {}", this.phoneRange);

  RandomEventGenerator phones = dag.addOperator("Receiver", RandomEventGenerator.class);
  phones.setMinvalue(this.phoneRange.getMinimum());
  phones.setMaxvalue(this.phoneRange.getMaximum());

  PhoneMovementGenerator movementGen = dag.addOperator("LocationFinder", PhoneMovementGenerator.class);
  dag.setAttribute(movementGen, OperatorContext.COUNTERS_AGGREGATOR, new BasicCounters.LongAggregator<MutableLong>());

  StatelessThroughputBasedPartitioner<PhoneMovementGenerator> partitioner = new StatelessThroughputBasedPartitioner<PhoneMovementGenerator>();
  partitioner.setCooldownMillis(conf.getLong(COOL_DOWN_MILLIS, 45000));
  partitioner.setMaximumEvents(conf.getLong(MAX_THROUGHPUT, 30000));
  partitioner.setMinimumEvents(conf.getLong(MIN_THROUGHPUT, 10000));
  dag.setAttribute(movementGen, OperatorContext.STATS_LISTENERS, Arrays.asList(new StatsListener[]{partitioner}));
  dag.setAttribute(movementGen, OperatorContext.PARTITIONER, partitioner);

  // generate seed numbers
  Random random = new Random();
  int maxPhone = phoneRange.getMaximum() - phoneRange.getMinimum();
  int phonesToDisplay = conf.getInt(TOTAL_SEED_NOS, 10);
  for (int i = phonesToDisplay; i-- > 0; ) {
    int phoneNo = phoneRange.getMinimum() + random.nextInt(maxPhone + 1);
    LOG.info("seed no: " + phoneNo);
    movementGen.phoneRegister.add(phoneNo);
  }
  // done generating data
  LOG.info("Finished generating seed data.");

  URI uri = PubSubHelper.getURI(dag);
  PubSubWebSocketOutputOperator<Object> wsOut = dag.addOperator("LocationResults", new PubSubWebSocketOutputOperator<Object>());
  wsOut.setUri(uri);
  PubSubWebSocketInputOperator<Map<String, String>> wsIn = dag.addOperator("QueryLocation", new PubSubWebSocketInputOperator<Map<String, String>>());
  wsIn.setUri(uri);
  // default partitioning: first connected stream to movementGen will be partitioned
  dag.addStream("Phone-Data", phones.integer_data, movementGen.data);
  dag.addStream("Results", movementGen.locationQueryResult, wsOut.input);
  dag.addStream("Query", wsIn.outputPort, movementGen.phoneQuery);
}
 
Example 19
Source File: TimeFrame.java    From dsworkbench with Apache License 2.0 4 votes vote down vote up
public Range<Long> getArriveRange() {
  return Range.between(arriveNotBefore, arriveNotAfter);
}
 
Example 20
Source File: TimeFrame.java    From dsworkbench with Apache License 2.0 4 votes vote down vote up
public List<Range<Long>> startTimespansToRanges() {
  List<Range<Long>> ranges = new LinkedList<>();
  Date startDate = DateUtils.truncate(new Date(startNotBefore), Calendar.DATE);

  for (TimeSpan span : sendTimeSpans) {
    if(!span.isValidAtEveryDay()) {
        Range<Long> range;
        //just copy range
        if(span.isValidAtExactTime()) {
          range = Range.between(span.getSpan().getMinimum(), span.getSpan().getMaximum() + fixedStartTimeRangeSize);
        } else {
          range = Range.between(span.getSpan().getMinimum(), span.getSpan().getMaximum());
        }
        
        if (range.getMaximum() > System.currentTimeMillis()) {
          if(range.getMinimum() <= System.currentTimeMillis()) {
              //rebuild Range
              range = Range.between(System.currentTimeMillis(), range.getMaximum());
          }
          //add range only if it is in future
          ranges.add(range);
        }
    }
    else {
      //span is valid for every day
      Date thisDate = new Date(startDate.getTime());
      //go through all days from start to end
      while (thisDate.getTime() < startNotAfter) {
        long spanStart = thisDate.getTime() + span.getSpan().getMinimum();
        long spanEnd = thisDate.getTime() + span.getSpan().getMaximum();
        Range<Long> newRange = null;
        //check span location relative to start frame
        if (spanStart >= startNotBefore && spanEnd > startNotBefore
            && spanStart < startNotAfter && spanEnd <= startNotAfter) {
          //|----------| (startNotBefore - startNotAfter)
          //  |----| (SpanStart - SpanEnd)
          newRange = Range.between(spanStart, spanEnd);
        } else if (spanStart < startNotBefore && spanEnd > startNotBefore
            && spanStart < startNotAfter && spanEnd <= startNotAfter) {
          //  |----------| (startNotBefore - startNotAfter)
          //|----| (SpanStart - SpanEnd)
          //set span start to 'startNotBefore'
          newRange = Range.between(startNotBefore, spanEnd);
        } else if (spanStart <= startNotBefore && spanEnd > startNotBefore
            && spanStart > startNotAfter && spanEnd >= startNotAfter) {
          //  |----------| (startNotBefore - startNotAfter)
          //|--------------| (SpanStart - SpanEnd)
          //set span start to 'startNotBefore'
          newRange = Range.between(startNotBefore, startNotAfter);
        } else if (spanStart >= startNotBefore && spanEnd > startNotBefore
            && spanStart < startNotAfter && spanEnd >= startNotAfter) {
          //|----------| (startNotBefore - startNotAfter)
          //    |---------| (SpanStart - SpanEnd)
          //set span start to 'startNotBefore'
          newRange = Range.between(spanStart, startNotAfter);
        }

        if (newRange != null) {
          if (newRange.getMinimum() < System.currentTimeMillis()) {
            //check minimum as current minimum is in past
            if (newRange.getMaximum() > System.currentTimeMillis()) {
              newRange = Range.between(System.currentTimeMillis(), newRange.getMaximum());
              ranges.add(newRange);
            }//ignore as entire range is in past
          } else {
            //add range as it is in future
            ranges.add(newRange);
          }
        }
        //increment current date by one day
        thisDate = DateUtils.addDays(thisDate, 1);
      }
    }
  }
  Collections.sort(ranges, new Comparator<Range<Long>>() {
    @Override
    public int compare(Range<Long> o1, Range<Long> o2) {
      return o1.getMinimum().compareTo(o2.getMinimum());
    }
  });
  return ranges;
}