package seedu.ezdo.model.todo;

import java.util.Iterator;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.ezdo.commons.util.CollectionUtil;

/**
 * A list of done tasks whose tasks are guaranteed to be unique and does not allow nulls.
 *
 * Supports a minimal set of list operations.
 *
 * @see Task#equals(Object)
 * @see CollectionUtil#elementsAreUnique(Collection)
 */
public class UniqueDoneList implements Iterable<Task> {

    private final ObservableList<Task> internalList = FXCollections.observableArrayList();

    /**
     * Returns true if the list contains an equivalent task as the given argument.
     */
    public boolean contains(ReadOnlyTask toCheck) {
        assert toCheck != null;
        return internalList.contains(toCheck);
    }

    /**
     * Adds a task to the done list.
     *
     * @throws DuplicateTaskException if the task to add is a duplicate of an existing task in the list.
     */
    public void add(Task toAdd) {
        assert toAdd != null;
        internalList.add(toAdd);
    }
    
    @Override
    public Iterator<Task> iterator() {
        return internalList.iterator();
    }

    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof UniqueTaskList // instanceof handles nulls
                && this.internalList.equals(
                ((UniqueDoneList) other).internalList));
    }

    @Override
    public int hashCode() {
        return internalList.hashCode();
    }
}

@@ -51,16 +51,39 @@
 terator;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -210,76 +210,104 @@
 il;%0A
-%0A/**%0A * A list of done tasks whose tasks are guaranteed to be unique
+import seedu.ezdo.model.todo.UniqueTaskList.DuplicateTaskException;%0A%0A/**%0A * A list of done tasks
  and
@@ -514,16 +514,24 @@
 terable%3C
+ReadOnly
 Task%3E %7B%0A
@@ -564,16 +564,24 @@
 bleList%3C
+ReadOnly
 Task%3E in
@@ -1053,16 +1053,24 @@
 oid add(
+ReadOnly
 Task toA
@@ -1149,16 +1149,408 @@
  %7D%0A    %0A
+    public void setDone(UniqueDoneList replacement) %7B%0A        this.internalList.setAll(replacement.internalList);%0A    %7D%0A%0A    public void setDone(List%3C? extends ReadOnlyTask%3E tasks) %7B%0A        final UniqueDoneList replacement = new UniqueDoneList();%0A        for (final ReadOnlyTask task : tasks) %7B%0A            replacement.add(new Task(task));%0A        %7D%0A        setDone(replacement);%0A    %7D%0A    %0A
     @Ove
@@ -1575,16 +1575,24 @@
 terator%3C
+ReadOnly
 Task%3E it

Change Tasks to ReadOnlyTasks