public MaxTemperatureProfilSwitchPoint getSwitchPoint(Time time) {
    List<MaxTemperatureProfilSwitchPoint> points =
        new ArrayList<MaxTemperatureProfilSwitchPoint>(getSwitchPoints());
    if (points.isEmpty()) return null;

    Collections.reverse(points);

    MaxTemperatureProfilSwitchPoint best = null;
    for (MaxTemperatureProfilSwitchPoint sp : points) {
      if (best == null) {
        best = sp;
        continue;
      }
      Time stop = sp.getStopAsTime();
      if (stop.isBefore(time)) return best;
      best = sp;
    }
    return best;
  }
Esempio n. 2
0
  public List<ProjectEvent> getLatestProjectEvents(int min) {
    List<ProjectEvent> events = getProjectEvents();
    Collections.sort(events, ProjectEvent.DATE_AND_TIME_COMPARATOR);

    DateAndTime deadline = new DateAndTime(Date.today().prevDay(), Time.now());
    List<ProjectEvent> ret = new ArrayList<ProjectEvent>();
    int count = 0;
    for (ProjectEvent event : events) {
      ret.add(event);
      count++;
      DateAndTime dateAndTime = event.getDateAndTime();
      if (count > min && dateAndTime.isBefore(deadline)) break;
    }
    return ret;
  }
 public MaxTemperatureProfilSwitchPoint getSwitchPointForNow() {
   return getSwitchPoint(Time.now());
 }