package seedu.doist.model.task;

import java.util.Comparator;

import seedu.doist.model.tag.UniqueTagList;
import seedu.doist.model.task.Priority.PriorityLevel;

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

    Description getDescription();
    Priority getPriority();
    FinishedStatus getFinishedStatus();
    /**
     * The returned TagList is a deep copy of the internal TagList,
     * changes on the returned list will not affect the person's internal tags.
     */
    UniqueTagList getTags();

    /**
     * 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
                && other.getDescription().equals(this.getDescription())
                && other.getFinishedStatus().equals(this.getFinishedStatus())); // state checks here onwards
    }

    /**
     * Formats the task as text, showing description and tags
     */
    default String getAsText() {
        final StringBuilder builder = new StringBuilder();
        builder.append(getDescription());
        getTags().forEach(builder::append);
        return builder.toString();
    }

    /**
     * Compare the priority of two tasks
     * @return: -1 task2 has a lower priority than task1
     */
    public class ReadOnlyTaskPriorityComparator implements Comparator<ReadOnlyTask> {
        @Override
        public int compare(ReadOnlyTask task1, ReadOnlyTask task2) {
            // Highest priority to lowest priority
            PriorityLevel task1Priority = task1.getPriority().getPriorityLevel();
            PriorityLevel task2Priority = task2.getPriority().getPriorityLevel();
            return task2Priority.compareTo(task1Priority);
        }
    }
}

@@ -54,16 +54,39 @@
 parator;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -2030,11 +2030,1034 @@
  %7D%0A    %7D
+%0A%0A    /**%0A     * Combines multiple comparators together to compare tasks.%0A     * For example if you want to sort by end time then by priority,%0A     * you create a list of comparators, adding the end time comparator first%0A     * then adding the priority comparator.%0A     * @return: -1 task1 is compared to be %22less%22 than task2 based on multiple comparators%0A     */%0A    public class CombinedComparator implements Comparator%3CReadOnlyTask%3E %7B%0A%0A        List%3CComparator%3CReadOnlyTask%3E%3E comparators;%0A%0A        public CombinedComparator(List%3CComparator%3CReadOnlyTask%3E%3E comparators) %7B%0A            this.comparators = comparators;%0A        %7D%0A%0A        @Override%0A        public int compare(ReadOnlyTask task1, ReadOnlyTask task2) %7B%0A            int compareResult = 0;%0A            for (Comparator%3CReadOnlyTask%3E comparator : comparators) %7B%0A                if (comparator.compare(task1, task2) != 0) %7B%0A                    return comparator.compare(task1, task2);%0A                %7D%0A            %7D%0A            return compareResult;%0A        %7D%0A%0A    %7D
 %0A%7D%0A

Prepare for multiple comparators being combined together