package uk.ac.ebi.quickgo.rest.period;

import com.google.common.base.Preconditions;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * An implementation of a {@link AlarmClock} which uses two values of {@link DateModifier} as start and end points to
 * determine remaining time.
 *
 * @author Tony Wardell
 * Date: 11/04/2017
 * Time: 12:46
 * Created with IntelliJ IDEA.
 */
public class AlarmClockImpl implements AlarmClock {

    private final DateModifier start;
    private final DateModifier end;

    AlarmClockImpl(DateModifier start, DateModifier end) {
        Preconditions.checkArgument(Objects.nonNull(start), "The RemainingTimePeriod constructor start parameter " +
                "must not be null.");
        Preconditions.checkArgument(Objects.nonNull(end),"The RemainingTimePeriod constructor end parameter " +
                "must not be null.");
        this.start = start;
        this.end = end;
    }

    @Override
    public Duration remainingTime(LocalDateTime target) {
        LocalDateTime startDateTime = start.modify(target);
        LocalDateTime endDateTime = end.modify(target);
        Duration remaining;
        if (target.isAfter(startDateTime) && target.isBefore(endDateTime)){
            remaining = Duration.between(target, endDateTime);
        }else{
            remaining = Duration.ZERO;
        }
        return remaining;
    }

    @Override public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        AlarmClockImpl that = (AlarmClockImpl) o;

        if (start != null ? !start.equals(that.start) : that.start != null) {
            return false;
        }
        return end != null ? end.equals(that.end) : that.end == null;
    }

    @Override public int hashCode() {
        int result = start != null ? start.hashCode() : 0;
        result = 31 * result + (end != null ? end.hashCode() : 0);
        return result;
    }

    @Override public String toString() {
        return "RemainingTimePeriod{" +
                "start=" + start +
                ", end=" + end +
                '}';
    }
}

@@ -162,16 +162,73 @@
 Objects;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0A/**%0A *
@@ -522,16 +522,104 @@
 lock %7B%0A%0A
+    private static final Logger LOGGER = LoggerFactory.getLogger(AlarmClockImpl.class);%0A
     priv
@@ -685,16 +685,17 @@
 r end;%0A%0A
+%0A
     Alar
@@ -1289,32 +1289,203 @@
 modify(target);%0A
+        LOGGER.info(%22AlarmClockImpl calculating remaining time between %22 + startDateTime + %22 to %22 + endDateTime +%0A                            %22starting from %22 + target);%0A%0A
         Duration
@@ -1689,16 +1689,16 @@
 n.ZERO;%0A
-
         
@@ -1691,32 +1691,102 @@
 ZERO;%0A        %7D%0A
+        LOGGER.info(%22AlarmClockImpl remaining time is %22 + remaining);%0A
         return r

Add logging