package seedu.task.model.task;

import seedu.task.commons.exceptions.IllegalValueException;

/**
 * Represents a Task's description in the ToDo list.
 * Guarantees: immutable; is valid as declared in {@link #isValidDescription(String)}
 */
public class Description {

    public static final String MESSAGE_DESCRIPTION_CONSTRAINTS =
            "Task descriptions should only contain alphanumeric characters and spaces, and it should not be blank";

    /*
     * The first character of the task must not be a whitespace,
     * otherwise " " (a blank string) becomes a valid input.
     */
    public static final String DESCRIPTION_VALIDATION_REGEX = "^[A-Za-z, ]++$";

    public final String description;

    /**
     * Validates given description.
     *
     * @throws IllegalValueException if given description string is invalid.
     */
    public Description(String description) throws IllegalValueException {
        assert description != null;
        String trimmedDescription = description.trim();
        if (!isValidDescription(trimmedDescription)) {
            throw new IllegalValueException(MESSAGE_DESCRIPTION_CONSTRAINTS);
        }
        this.description = trimmedDescription;
    }

    /**
     * Returns true if a given string is a valid description.
     */
    public static boolean isValidDescription(String test) {
        return test.matches(DESCRIPTION_VALIDATION_REGEX);
    }


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

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

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

}

@@ -25,16 +25,46 @@
 .task;%0A%0A
+import java.util.Comparator;%0A%0A
 import s
@@ -287,16 +287,51 @@
 cription
+ implements Comparable%3CDescription%3E
  %7B%0A%0A    
@@ -1762,16 +1762,24 @@
         
+        
 && this.
@@ -1944,10 +1944,413 @@
 %0A    %7D%0A%0A
+    @Override%0A    public int compareTo(Description other) %7B%0A        return this.description.compareTo(other.description);%0A    %7D%0A%0A    public static Comparator%3CDescription%3E DescriptionComparator = new Comparator%3CDescription%3E() %7B%0A%0A        @Override%0A        public int compare(Description description1, Description description2) %7B%0A            return description1.compareTo(description2);%0A        %7D%0A%0A    %7D;%0A%0A
 %7D%0A

make Description.java comparable