/**
  * Compares this object with the specified object for equality based on start and end millis plus
  * the chronology. All ReadableInterval instances are accepted.
  *
  * <p>To compare the duration of two time intervals, use {@link #toDuration()} to get the
  * durations and compare those.
  *
  * @param readableInterval a readable interval to check against
  * @return true if the intervals are equal comparing the start millis, end millis and chronology
  */
 public boolean equals(Object readableInterval) {
   if (this == readableInterval) {
     return true;
   }
   if (readableInterval instanceof ReadableInterval == false) {
     return false;
   }
   ReadableInterval other = (ReadableInterval) readableInterval;
   return getStartMillis() == other.getStartMillis()
       && getEndMillis() == other.getEndMillis()
       && FieldUtils.equals(getChronology(), other.getChronology());
 }
Пример #2
0
  public static boolean isContainedIn(Absence a, ReadableInterval i) {
    if (a.getType() == null || i == null) return false;

    Chronology chron = i.getChronology();

    switch (a.getType()) {
      case Absence:
        return i.contains(a.getInterval(chron));
      case EarlyCheckOut:
        DateTime checkout = a.getCheckout(chron);
        return i.contains(checkout);
      case Tardy:
        DateTime checkin = a.getCheckin(chron);
        return i.contains(checkin);
      default:
        throw new UnsupportedOperationException();
    }
  }