package seedu.address.model.task;

import java.util.Objects;
import java.util.Optional;

import seedu.address.model.tag.UniqueTagList;

/**
 * A read-only immutable interface for a Task in the task list.
 * Implementations should guarantee: details are present and not null, field values are validated.
 */
public interface ReadOnlyTask {

    /**
     * Gets the name of the task.
     */
    // TODO implementations must ensure this gets a deep copy or Name have no setter so it is not mutable.
    Name getName();

    /**
     * Gets the {@link Optional} deadline of the task.
     */
    // TODO implementations must ensure this gets a deep copy or Deadline have no setter so it is not mutable.
    Optional<Deadline> getDeadline();

    /**
     * Gets the {@link Optional} start and end date time of the task.
     */
    // TODO implementations must ensure this gets a deep copy or StartEndDateTime have no setter so it is not mutable.
    Optional<StartEndDateTime> getStartEndDateTime();

    /**
     * The returned TagList is a deep copy of the internal TagList,
     * changes on the returned list will not affect the task's internal tags.
     */
    UniqueTagList getTags();

    //@@author A0140023E
    /**
     * Returns true if both have the same state. (interfaces cannot override .equals)
     */
    default boolean isSameStateAs(ReadOnlyTask o) {
        if (o == null) {
            return false;
        }
        if (o == this) {
            return true;
        }
        if (this.getClass() != o.getClass()) {
            return false;
        }
        final ReadOnlyTask other = (ReadOnlyTask) o;

        return Objects.equals(getName(), other.getName())
                && Objects.equals(getDeadline(), other.getDeadline())
                && Objects.equals(getStartEndDateTime(), other.getStartEndDateTime());
        // TODO tags should actually be checked because that's how equals should usually function
        // However, the equals here is used to check for duplicates and is not really consistent
        // with how equals behave. Thus to further investigate.
        // Furthermore, this current implementation does not allow Tasks with same name to go through
        // if there are no deadlines or start and end date time. Probably would be better to remove
        // the duplicate task exception in this case.
    }

    /**
     * Formats the task as text, showing all fields.
     */
    default String getAsText() {
        final StringBuilder builder = new StringBuilder();
        buildNameString(builder);
        buildDeadlineString(builder);
        buildStartEndDateTimeString(builder);
        buildTagsString(builder);

        return builder.toString();
    }

    default void buildNameString(final StringBuilder builder) {
        builder.append(getName());
    }

    default void buildDeadlineString(final StringBuilder builder) {
        builder.append(" Deadline: ");
        builder.append(getDeadline().isPresent() ? getDeadline().get().toString() : "none");
    }

    default void buildStartEndDateTimeString(final StringBuilder builder) {
        if (getStartEndDateTime().isPresent()) {
            builder.append(" ");
            builder.append(getStartEndDateTime().get().toString());
        } else {
            builder.append(" Start Date: none ");
            builder.append(" End Date: none ");
        }
    }

    default void buildTagsString(final StringBuilder builder) {
        builder.append(" Tags: ");
        getTags().forEach(builder::append);
    }

}

@@ -2880,32 +2880,94 @@
 lder builder) %7B%0A
+        // TODO don't include milliseconds in toString output%0A
         builder.
@@ -3157,32 +3157,94 @@
 lder builder) %7B%0A
+        // TODO don't include milliseconds in toString output%0A
         if (getS

Add TODO tag to remove milliseconds display in ReadOnlyTask