<commit_before>package seedu.unburden.model.task;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.unburden.commons.exceptions.*;
import seedu.unburden.commons.util.CollectionUtil;


import java.util.*;

/**
 * A list of persons that enforces uniqueness between its elements and does not allow nulls.
 *
 * Supports a minimal set of list operations.
 *
 * @see Task#equals(Object)
 * @see CollectionUtil#elementsAreUnique(Collection)
 */
public class UniqueTaskList implements Iterable<Task> {

    /**
     * Signals that an operation would have violated the 'no duplicates' property of the list.
     */
    public static class DuplicateTaskException extends DuplicateDataException {
        protected DuplicateTaskException() {
            super("Operation would result in duplicate tasks");
        }
    }

    /**
     * Signals that an operation targeting a specified person in the list would fail because
     * there is no such matching person in the list.
     */
    public static class TaskNotFoundException extends Exception {}

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

    /**
     * Constructs empty PersonList.
     */
    public UniqueTaskList() {}

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

    /**
     * Adds a person to the list.
     *
     * @throws DuplicatePersonException if the person to add is a duplicate of an existing person in the list.
     */
    public void add(Task toAdd) throws DuplicateTaskException {
        assert toAdd != null;
        if (contains(toAdd)) {
            throw new DuplicateTaskException();
        }
        internalList.add(toAdd);
        FXCollections.sort(internalList);
    }
    

    /**
     * Removes the equivalent person from the list.
     *
     * @throws PersonNotFoundException if no such person could be found in the list.
     */
    public boolean remove(ReadOnlyTask toRemove) throws TaskNotFoundException {
        assert toRemove != null;
        final boolean taskFoundAndDeleted = internalList.remove(toRemove);
        if (!taskFoundAndDeleted) {
            throw new TaskNotFoundException();
        }
        FXCollections.sort(internalList);
        return taskFoundAndDeleted;
    }
    
    //@@<NAME> A0139714B
    public boolean edit(ReadOnlyTask key, Task toEdit) 
    		throws TaskNotFoundException, IllegalValueException {
    	
    	int taskIndex = internalList.indexOf(key);
    	Task updatedTask = toEdit;
    	Task oldTask = internalList.get(taskIndex);
    	
    	if (updatedTask.getName().getFullName() == "") {
    		updatedTask.setName(oldTask.getName());
    	}
    	
    	if (updatedTask.getTaskDescription().getFullTaskDescription() == "") {
    		updatedTask.setTaskDescription(oldTask.getTaskDescription());
    	}
    	
    	if (updatedTask.getDate().getFullDate() == "") {
    		updatedTask.setDate(oldTask.getDate());
    	}
    	
    	if (updatedTask.getStartTime().getFullTime() == "") {
    		updatedTask.setStartTime(oldTask.getStartTime());
    	}
    	
    	if (updatedTask.getEndTime().getFullTime() == "") {
    		updatedTask.setEndTime(oldTask.getEndTime());
    	}
    	
    	updatedTask.setTags(oldTask.getTags());
    	internalList.set(taskIndex, updatedTask);
    	FXCollections.sort(internalList);
	
    	return true;
      
    }
    

    public ObservableList<Task> getInternalList() {
        return internalList;
    }

    @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(
                ((UniqueTaskList) other).internalList));
    }

    @Override
    public int hashCode() {
        return internalList.hashCode();
    }
    
    
    //@@ <NAME> A0139714B
	public void done(ReadOnlyTask key, boolean isDone) {
		assert key != null;
		int taskIndex = internalList.indexOf(key);
        Task newTask = internalList.get(taskIndex);
        newTask.setDone(isDone);
        internalList.set(taskIndex, newTask);
	}
	
	public void undone(ReadOnlyTask key, boolean isDone) {
		assert key != null;
		int taskIndex = internalList.indexOf(key);
        Task newTask = internalList.get(taskIndex);
        newTask.setDone(isDone);
        internalList.set(taskIndex, newTask);
	}
}
<commit_msg>added assertions<commit_after>package seedu.unburden.model.task;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.unburden.commons.exceptions.*;
import seedu.unburden.commons.util.CollectionUtil;


import java.util.*;

/**
 * A list of persons that enforces uniqueness between its elements and does not allow nulls.
 *
 * Supports a minimal set of list operations.
 *
 * @see Task#equals(Object)
 * @see CollectionUtil#elementsAreUnique(Collection)
 */
public class UniqueTaskList implements Iterable<Task> {

    /**
     * Signals that an operation would have violated the 'no duplicates' property of the list.
     */
    public static class DuplicateTaskException extends DuplicateDataException {
        protected DuplicateTaskException() {
            super("Operation would result in duplicate tasks");
        }
    }

    /**
     * Signals that an operation targeting a specified person in the list would fail because
     * there is no such matching person in the list.
     */
    public static class TaskNotFoundException extends Exception {}

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

    /**
     * Constructs empty PersonList.
     */
    public UniqueTaskList() {}

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

    /**
     * Adds a person to the list.
     *
     * @throws DuplicatePersonException if the person to add is a duplicate of an existing person in the list.
     */
    public void add(Task toAdd) throws DuplicateTaskException {
        assert toAdd != null;
        if (contains(toAdd)) {
            throw new DuplicateTaskException();
        }
        internalList.add(toAdd);
        FXCollections.sort(internalList);
    }
    

    /**
     * Removes the equivalent person from the list.
     *
     * @throws PersonNotFoundException if no such person could be found in the list.
     */
    public boolean remove(ReadOnlyTask toRemove) throws TaskNotFoundException {
        assert toRemove != null;
        final boolean taskFoundAndDeleted = internalList.remove(toRemove);
        if (!taskFoundAndDeleted) {
            throw new TaskNotFoundException();
        }
        FXCollections.sort(internalList);
        return taskFoundAndDeleted;
    }
    
    //@@<NAME> A0139714B
    public boolean edit(ReadOnlyTask key, Task toEdit) 
    		throws TaskNotFoundException, IllegalValueException {
    	
    	assert toEdit != null;
    	assert key != null;
    	int taskIndex = internalList.indexOf(key);
    	Task updatedTask = toEdit;
    	Task oldTask = internalList.get(taskIndex);
    	
    	if (updatedTask.getName().getFullName() == "") {
    		updatedTask.setName(oldTask.getName());
    	}
    	
    	if (updatedTask.getTaskDescription().getFullTaskDescription() == "") {
    		updatedTask.setTaskDescription(oldTask.getTaskDescription());
    	}
    	
    	if (updatedTask.getDate().getFullDate() == "") {
    		updatedTask.setDate(oldTask.getDate());
    	}
    	
    	if (updatedTask.getStartTime().getFullTime() == "") {
    		updatedTask.setStartTime(oldTask.getStartTime());
    	}
    	
    	if (updatedTask.getEndTime().getFullTime() == "") {
    		updatedTask.setEndTime(oldTask.getEndTime());
    	}
    	
    	updatedTask.setTags(oldTask.getTags());
    	internalList.set(taskIndex, updatedTask);
    	FXCollections.sort(internalList);
	
    	return true;
      
    }
    

    public ObservableList<Task> getInternalList() {
        return internalList;
    }

    @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(
                ((UniqueTaskList) other).internalList));
    }

    @Override
    public int hashCode() {
        return internalList.hashCode();
    }
    
    
    //@@ <NAME>oshi A0139714B
	public void done(ReadOnlyTask key, boolean isDone) {
		assert key != null;
		int taskIndex = internalList.indexOf(key);
        Task newTask = internalList.get(taskIndex);
        newTask.setDone(isDone);
        internalList.set(taskIndex, newTask);
	}
	
	public void undone(ReadOnlyTask key, boolean isDone) {
		assert key != null;
		int taskIndex = internalList.indexOf(key);
        Task newTask = internalList.get(taskIndex);
        newTask.setDone(isDone);
        internalList.set(taskIndex, newTask);
	}
}

{'fraction_non_alphanumeric': 0.09569074778200254, 'fraction_numerical': 0.002957329953527672, 'mean_word_length': 2.7367797947908445, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7658116', 'n_tokens_mistral': 2653, 'n_tokens_neox': 2579, 'n_words': 665}