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

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

/**
 * Data structure holds union of day of week and time. Used to declare events that have a daily occurrence at a set
 * time.
 *
 * @author Tony Wardell
 * Date: 11/04/2017
 * Time: 16:15
 * Created with IntelliJ IDEA.
 */
class DayTime implements DateModifier {

    private final DayOfWeek dayOfWeek;
    private final LocalTime time;

    /**
     * Given a target time, this method returns a {@link LocalDateTime} instance that has the same day and time as
     * target.
     * @param dayOfWeek this class represents.
     * @param time this class represents.
     */
    DayTime(DayOfWeek dayOfWeek, LocalTime time) {
        Preconditions.checkArgument(Objects.nonNull(dayOfWeek), "Invalid DayOfWeek parameter passed to " +
                "DayTime constructor. Parameter is null, it should be a valid DayOfWeek instance.");
        Preconditions.checkArgument(Objects.nonNull(time), "Invalid time parameter passed to DayTime constructor. " +
                "Parameter was null, it should be a valid LocalTime instance.");
        this.dayOfWeek = dayOfWeek;
        this.time = time;
    }

    /**
     * Modify the targetTime to be an instant defined by the values held in this instance.
     * @param target to modify.
     * @return a particular instant in time.
     */
    @Override
    public LocalDateTime modify(LocalDateTime target) {
        Preconditions.checkArgument(Objects.nonNull(target), "A target LocalDateTime cannot be null");
        LocalDateTime comparedDate = target.with(this.dayOfWeek);
        return comparedDate.with(this.time);
    }
}

@@ -1769,11 +1769,799 @@
 );%0A    %7D
+%0A%0A    @Override public boolean equals(Object o) %7B%0A        if (this == o) %7B%0A            return true;%0A        %7D%0A        if (o == null %7C%7C getClass() != o.getClass()) %7B%0A            return false;%0A        %7D%0A%0A        DayTime dayTime = (DayTime) o;%0A%0A        if (dayOfWeek != dayTime.dayOfWeek) %7B%0A            return false;%0A        %7D%0A        return time != null ? time.equals(dayTime.time) : dayTime.time == null;%0A    %7D%0A%0A    @Override public int hashCode() %7B%0A        int result = dayOfWeek != null ? dayOfWeek.hashCode() : 0;%0A        result = 31 * result + (time != null ? time.hashCode() : 0);%0A        return result;%0A    %7D%0A%0A    @Override public String toString() %7B%0A        return %22DayTime%7B%22 +%0A                %22dayOfWeek=%22 + dayOfWeek +%0A                %22, time=%22 + time +%0A                '%7D';%0A    %7D
 %0A%7D%0A

Add equals, hashcode, toString.