@@ -0,0 +1,2815 @@
+package tars.model.task.rsv;%0A%0Aimport java.util.Collection;%0Aimport java.util.Iterator;%0A%0Aimport javafx.collections.FXCollections;%0Aimport javafx.collections.ObservableList;%0Aimport tars.commons.exceptions.DuplicateTaskException;%0Aimport tars.commons.util.CollectionUtil;%0A%0A/**%0A * A list of reserved tasks that enforces uniqueness between its elements and%0A * does not allow nulls.%0A *%0A * Supports a minimal set of list operations.%0A * %0A * @@author A0124333U%0A *%0A * @see RsvTask#equals(Object)%0A * @see CollectionUtil#elementsAreUnique(Collection)%0A */%0A%0Apublic class UniqueRsvTaskList implements Iterable%3CRsvTask%3E %7B%0A%0A    /**%0A     * Signals that an operation targeting a specified task in the list would%0A     * fail because there is no such matching task in the list.%0A     */%0A    public static class TaskNotFoundException extends Exception %7B%0A    %7D%0A%0A    private final ObservableList%3CRsvTask%3E internalList = FXCollections.observableArrayList();%0A%0A    /**%0A     * Constructs empty RsvTaskList.%0A     */%0A    public UniqueRsvTaskList() %7B%0A    %7D%0A%0A    /**%0A     * Returns true if the list contains an equivalent reserved task as the%0A     * given argument.%0A     */%0A    public boolean contains(RsvTask toCheck) %7B%0A        assert toCheck != null;%0A        return internalList.contains(toCheck);%0A    %7D%0A%0A    /**%0A     * Adds a reserved task to the list.%0A     *%0A     * @throws DuplicateTaskException%0A     *             if the reserved task to add is a duplicate of an existing%0A     *             reserved task in the list.%0A     */%0A    public void add(RsvTask toAdd) throws DuplicateTaskException %7B%0A        assert toAdd != null;%0A        if (contains(toAdd)) %7B%0A            throw new DuplicateTaskException();%0A        %7D%0A        internalList.add(toAdd);%0A    %7D%0A%0A    /**%0A     * Removes the equivalent task from the list.%0A     *%0A     * @throws TaskNotFoundException%0A     *             if no such task could be found in the list.%0A     */%0A    public boolean remove(RsvTask toRemove) throws TaskNotFoundException %7B%0A        assert toRemove != null;%0A        final boolean taskFoundAndDeleted = internalList.remove(toRemove);%0A        if (!taskFoundAndDeleted) %7B%0A            throw new TaskNotFoundException();%0A        %7D%0A        return taskFoundAndDeleted;%0A    %7D%0A%0A    public ObservableList%3CRsvTask%3E getInternalList() %7B%0A        return internalList;%0A    %7D%0A%0A    @Override%0A    public Iterator%3CRsvTask%3E iterator() %7B%0A        return internalList.iterator();%0A    %7D%0A    %0A    @Override%0A    public boolean equals(Object other) %7B%0A        return other == this // short circuit if same object%0A                %7C%7C (other instanceof UniqueRsvTaskList // instanceof handles nulls%0A                && this.internalList.equals(%0A                ((UniqueRsvTaskList) other).internalList));%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return internalList.hashCode();%0A    %7D%0A%0A%7D%0A

Add UniqueRsvTaskList to ensure uniquness between RsvTask objects