//@@author A0147984L
package seedu.address.model.task;

import seedu.address.model.tag.Tag;

/**
 * A read-only immutable interface for a Task in the TaskManager.
 * Implementations should guarantee: details are present and not null, field values are validated.
 */
public interface ReadOnlyTask {
    public enum FinishProperty {
        FINISHED, UNFINISHED
    }
    public enum EventProperty {
        EVENT, NON_EVENT
    }

    Name getName();
    TaskDate getDate();
    TaskTime getTime();
    Tag getTag();
    Description getDescription();
    Venue getVenue();
    Priority getPriority();
    boolean isFavorite();
    boolean isFinished();
    String getFavoriteText();
    String getFinishedText();
    boolean isEvent();

    /**
     * Returns true if both have the same state. (interfaces cannot override equals)
     */
    default boolean isSameStateAs(ReadOnlyTask other) {
        return other == this // short circuit if same object
                || (other != null // this is first to avoid NPE below
                && checkEqual(this.getName(), other.getName())
                && checkEqual(this.getDate(), other.getDate())
                && checkEqual(this.getTime(), other.getTime())
                && checkEqual(this.getTag(), other.getTag())
                && ((other.getFinished() == null && this.getFinished() == null)
                        || (other.getFinished() != null && other.getFinished().equals(this.getFinished()))));
                // state checks here onwards
    }
    //@@ author A0147996E
    /**
     * For comparing two tasks in GUItests, to check if the list view matches desired list view.
     */
    default boolean isSameCardAs(ReadOnlyTask other) {
        return other == this // short circuit if same object
                || (other != null // this is first to avoid NPE below
                && checkEqual(this.getName(), other.getName())
                && checkEqual(this.getDate(), other.getDate())
                && checkEqual(this.getTime(), other.getTime())
                && checkEqual(this.getTag(), other.getTag())
                && ((other.getFinished() == null && this.getFinished() == null)
                        || (other.getFinished() != null && other.getFinished().equals(this.getFinished()))));
    }

    //@@ author A0143409J
    /*
     * Get the FinishProperty instead of boolean
     */
    FinishProperty getFinished();
    EventProperty getEventProperty();

    /*
     * Ensure there is no null pointer exception when comparing two TaskFields
     */
    default boolean checkEqual(TaskField mine, TaskField other) {
        if (mine == null) {
            return other == null;
        } else {
            return mine.equals(other);
        }
    }

    /**
     * Formats the person as text, showing all contact details.
     */
    default String getAsText() {
        final StringBuilder builder = new StringBuilder();
        builder.append(getName());
        if (getDate() != null) {
            builder.append("  Due Date:");
            builder.append(getDate());
        }
        if (getTime() != null) {
            builder.append("  Time:");
            builder.append(getTime());
        }
        if (getDescription() != null) {
            builder.append("  Description:");
            builder.append(getDescription());
        }
        if (getTag() != null) {
            builder.append("  List:");
            builder.append(getTag());
        }
        if (getVenue() != null) {
            builder.append("  Venue:");
            builder.append(getVenue());
        }
        assert getPriority() != null;
        builder.append("  Priority:");
        builder.append(getPriority());
        if (isFavorite()) {
            builder.append(" favorite");
        }
        if (isFinished()) {
            builder.append(" finished");
        }
        return builder.toString();
    }
}

@@ -878,32 +878,148 @@
 lyTask other) %7B%0A
+        if (this.isEvent() %5E other.isEvent()) %7B%0A            return false;%0A        %7D else if (!this.isEvent()) %7B%0A    
         return o
@@ -1071,32 +1071,36 @@
                 
+    
 %7C%7C (other != nul
@@ -1129,32 +1129,36 @@
 avoid NPE below%0A
+    
                 
@@ -1212,32 +1212,36 @@
                 
+    
 && checkEqual(th
@@ -1263,32 +1263,36 @@
 ther.getDate())%0A
+    
                 
@@ -1346,32 +1346,36 @@
                 
+    
 && checkEqual(th
@@ -1395,32 +1395,36 @@
 other.getTag())%0A
+    
                 
@@ -1503,32 +1503,36 @@
                 
+ 
+   
 %7C%7C (other.getFin
@@ -1617,16 +1617,20 @@
         
+    
 // state
@@ -1650,16 +1650,921 @@
 onwards%0A
+        %7D else %7B%0A            return other == this // short circuit if same object%0A                    %7C%7C (other != null // this is first to avoid NPE below%0A                    && checkEqual(this.getName(), other.getName())%0A                    && checkEqual(this.getDate(), other.getDate())%0A                    && checkEqual(this.getTime(), other.getTime())%0A                    && checkEqual(((ReadOnlyEvent) this).getStartDate(), ((ReadOnlyEvent) other).getStartDate())%0A                    && checkEqual(((ReadOnlyEvent) this).getStartTime(), ((ReadOnlyEvent) other).getStartTime())%0A                    && checkEqual(this.getTag(), other.getTag())%0A                    && ((other.getFinished() == null && this.getFinished() == null)%0A                            %7C%7C (other.getFinished() != null && other.getFinished().equals(this.getFinished()))));%0A                    // state checks here onwards%0A        %7D%0A
     %7D%0A  
@@ -3786,24 +3786,34 @@
     %7D%0A    %7D%0A
+//@@author
 %0A    /**%0A   

Modify task isSameState check