private static Date pickLater(Date latestEarliestStart, Date earliest) {
   if (earliest != null) {
     if (latestEarliestStart == null) {
       latestEarliestStart = earliest;
     } else {
       latestEarliestStart = DateUtils.latest(earliest, latestEarliestStart);
     }
   }
   return latestEarliestStart;
 }
 private SuggestedStartTime getSimpleBounds(EPlanElement element) {
   Date latestEarliestStart = null;
   Date earliestLatestStart = null;
   Date latestEarliestEnd = null;
   Date earliestLatestEnd = null;
   for (PeriodicTemporalConstraint timepointConstraint :
       ConstraintUtils.getPeriodicConstraints(element, false)) {
     if (timepointConstraint.getWaiverRationale() != null) {
       continue; // skip this one because it is waived
     }
     Date earliest = ConstraintUtils.getPeriodicConstraintEarliestDate(timepointConstraint);
     Date latest = ConstraintUtils.getPeriodicConstraintLatestDate(timepointConstraint);
     switch (timepointConstraint.getPoint().getEndpoint()) {
       case START:
         latestEarliestStart = pickLater(latestEarliestStart, earliest);
         earliestLatestStart = pickEarlier(earliestLatestStart, latest);
         break;
       case END:
         latestEarliestEnd = pickLater(latestEarliestEnd, earliest);
         earliestLatestEnd = pickEarlier(earliestLatestEnd, latest);
         break;
       default:
         Logger.getLogger(SpifePlanConstraintInfo.class)
             .warn("unexpected timepoint: " + timepointConstraint.getPoint().getEndpoint());
     }
   }
   TemporalExtent extent = element.getMember(TemporalMember.class).getExtent();
   if (extent != null) {
     if (latestEarliestEnd != null) {
       Date earliest = DateUtils.subtract(latestEarliestEnd, extent.getDurationMillis());
       latestEarliestStart = pickLater(latestEarliestStart, earliest);
     }
     if (earliestLatestEnd != null) {
       Date latest = DateUtils.subtract(earliestLatestEnd, extent.getDurationMillis());
       earliestLatestStart = pickEarlier(earliestLatestStart, latest);
     }
   }
   if ((latestEarliestStart == null) || (earliestLatestStart == null)) {
     return null;
   }
   return new SuggestedStartTime(
       element, latestEarliestStart, latestEarliestStart, earliestLatestStart);
 }
 private static Date pickEarlier(Date earliestLatestStart, Date latest) {
   if (latest != null) {
     if (earliestLatestStart == null) {
       earliestLatestStart = latest;
     } else {
       earliestLatestStart = DateUtils.earliest(latest, earliestLatestStart);
     }
   }
   return earliestLatestStart;
 }
 private void addActivityEdges(TemporalEdgeManager manager, EActivity activity) {
   TemporalMember member = activity.getMember(TemporalMember.class);
   Date start = member == null ? null : member.getStartTime();
   Date end = member == null ? null : member.getEndTime();
   boolean instantaneous = DateUtils.same(start, end);
   List<Long> list = new ArrayList<Long>();
   if (instantaneous && start != null) {
     list.add(start.getTime());
   } else {
     if (start != null) {
       list.add(start.getTime());
     }
     if (end != null) {
       list.add(end.getTime());
     }
   }
   manager.addTimes(activity, list);
 }