package seedu.oneline.model.task;

import seedu.oneline.commons.exceptions.IllegalValueException;
import seedu.oneline.model.tag.Tag;

public class TaskName {

    public static final String MESSAGE_TASK_NAME_CONSTRAINTS = "Task names should be spaces or alphanumeric characters";
    public static final String TASK_NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+";

    public final String name;

    /**
     * Validates given name.
     *
     * @throws IllegalValueException if given name string is invalid.
     */
    public TaskName(String name) throws IllegalValueException {
        assert name != null;
        name = name.trim();
        if (!isValidTaskName(name)) {
            throw new IllegalValueException(MESSAGE_TASK_NAME_CONSTRAINTS);
        }
        this.name = name;
    }

    /**
     * Returns true if a given string is a valid task name.
     */
    public static boolean isValidTaskName(String test) {
        return test.matches(TASK_NAME_VALIDATION_REGEX);
    }


    @Override
    public String toString() {
        return name;
    }

    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof TaskName // instanceof handles nulls
                && this.name.equals(((TaskName) other).name)); // state check
    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }
    
    /**
     * Serialize field for storage
     */
    public String serialize() {
        return name;
    }
    
    /**
     * Deserialize from storage
     */
    public static TaskName deserialize(String args) throws IllegalValueException {
        return new TaskName(args);
    }
}

@@ -95,66 +95,62 @@
 on;%0A
-import seedu.oneline.model.tag.Tag;%0A%0Apublic class TaskName
+%0Apublic class TaskName implements Comparable%3CTaskName%3E
  %7B%0A%0A
@@ -1698,11 +1698,169 @@
 );%0A    %7D
+%0A%0A    //@@author A0138848M%0A    @Override%0A    public int compareTo(TaskName o) %7B%0A        assert name != null;%0A        return this.name.compareTo(o.name);%0A    %7D
 %0A%7D%0A

Implement TaskName comparable interface