package seedu.tasklist.model.task;

import seedu.tasklist.commons.exceptions.IllegalValueException;

public class Priority {
    public static final String MESSAGE_PRIORITY_CONSTRAINTS =
            "Task priorities should only contain 'high', 'medium', or 'low', and it should not be blank";

    /*
     * The first character of the address must not be a whitespace,
     * otherwise " " (a blank string) becomes a valid input.
     */
    public static final String PRIORITY_VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";

    public final String priority;

    /**
     * Validates given priority.
     *
     * @throws IllegalValueException if given name string is invalid.
     */
    public Priority(String priority) throws IllegalValueException {
        assert priority != null;
        String trimmedPriority = priority.trim();
        if (!isValidPriority(trimmedPriority)) {
            throw new IllegalValueException(MESSAGE_PRIORITY_CONSTRAINTS);
        }
        this.priority = trimmedPriority;
    }

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

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

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

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

@@ -29,16 +29,57 @@
 .task;%0A%0A
+import com.google.common.base.Optional;%0A%0A
 import s
@@ -560,16 +560,183 @@
 um%7D %5D*%22;
+%0A    public static final String PRIORITY_LOW = %22low%22;%0A    public static final String PRIORITY_MEDIUM = %22medium%22;%0A    public static final String PRIORITY_HIGH = %22high%22;
 %0A%0A    pu
@@ -1219,24 +1219,670 @@
 ity;%0A    %7D%0A%0A
+    public Priority(Optional%3CString%3E priority) throws IllegalValueException %7B%0A        if (priority.isPresent()) %7B%0A            String priorityString = priority.get();%0A            assert priority != null;%0A            if (!isValidPriority(priorityString)) %7B%0A                throw new IllegalValueException(MESSAGE_PRIORITY_CONSTRAINTS);%0A            %7D%0A            this.priority = getPriorityType(priorityString);%0A        %7D else %7B%0A            this.priority = null;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Returns true if Priority is present%0A     */%0A    public boolean isPriorityPresent(Optional%3CString%3E priority) %7B%0A        return priority.isPresent();%0A    %7D%0A%0A
     /**%0A    
@@ -1930,17 +1930,16 @@
 lid 
-Task name
+Priority
 .%0A  
@@ -2056,32 +2056,677 @@
 _REGEX);%0A    %7D%0A%0A
+    /**%0A     * Returns the priority type. Throws IllegalArgumentException if not available%0A     */%0A    public static String getPriorityType(String priority) throws IllegalArgumentException %7B%0A        String lowerCasePriority = priority.toLowerCase();%0A        if (lowerCasePriority.equals(PRIORITY_LOW)) %7B%0A            return PRIORITY_LOW;%0A        %7D else if (lowerCasePriority.equals(PRIORITY_MEDIUM)) %7B%0A            return PRIORITY_MEDIUM;%0A        %7D else if (lowerCasePriority.equals(PRIORITY_HIGH)) %7B%0A            return PRIORITY_HIGH;%0A        %7D else %7B%0A            throw new IllegalArgumentException(MESSAGE_PRIORITY_CONSTRAINTS);%0A        %7D%0A    %7D%0A%0A
     @Override%0A  

add constructor for Priority.java