package seedu.address.model.task;


import seedu.address.commons.exceptions.IllegalValueException;

/**
 * Represents a Task's priority in task manager.
 * Guarantees: immutable; is valid as declared in {@link #isValidPriority(String)}
 */
public class Priority {

    public static final String PRIORITY_1 = "1";
    public static final String PRIORITY_2 = "2";
    public static final String PRIORITY_3 = "3";
    public static final String PRIORITY_TRIVIAL = "trivial";
    public static final String PRIORITY_NORMAL = "normal";
    public static final String PRIORITY_IMPORTANT = "important";

    public static final String DEFAULT_PRIORITY = PRIORITY_2;

    public static final String MESSAGE_PRIORITY_CONSTRAINTS = "task priority can only be 1, 2, 3, trivial, normal, or important";
    //TODO: public static final String DATE_VALIDATION_REGEX =

    public final String value;

    /**
     * Validity given priority.
     *
     * @throws IllegalValueException if given priority string is invalid.
     */
    public Priority(String priority) throws IllegalValueException {
        if (priority == null) {
            this.value = DEFAULT_PRIORITY;
        } else {
            String trimmedPriority = priority.trim();
            //if (!isValidPriority(trimmedPriority)) {
             //   throw new IllegalValueException(MESSAGE_PRIORITY_CONSTRAINTS);
            //}
            this.value = convert(trimmedPriority);
        }
    }

    /**
     * Returns if a given string is a valid priority.
     */
    public static boolean isValidPriority(String test) {
        return test.equalsIgnoreCase(PRIORITY_1) || test.equalsIgnoreCase(PRIORITY_2) ||
                test.equalsIgnoreCase(PRIORITY_3) || test.equalsIgnoreCase(PRIORITY_TRIVIAL) ||
                test.equalsIgnoreCase(PRIORITY_NORMAL) || test.equalsIgnoreCase(PRIORITY_IMPORTANT);
    }

    /**
     * Convert English expressions into digits expressions
     */
    public String convert(String value) {
        if (value.equals(PRIORITY_TRIVIAL)) {
            return PRIORITY_1;
        } else if (value.equals(PRIORITY_NORMAL)) {
            return PRIORITY_2;
        } else if (value.equals(PRIORITY_IMPORTANT)) {
            return PRIORITY_3;
        } else {
            return value;
        }
    }

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

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

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

}

@@ -589,16 +589,68 @@
 ortant%22;
+%0A    public static final String PRIORITY_EMPTY = %22%22;
 %0A%0A    pu
@@ -1287,18 +1287,16 @@
         
-//
 if (!isV
@@ -1341,18 +1341,16 @@
         
-//
    throw
@@ -1404,16 +1404,40 @@
 STRAINTS
+ + %22 %22 + trimmedPriority
 );%0A     
@@ -1443,18 +1443,16 @@
         
-//
 %7D%0A      
@@ -1924,16 +1924,63 @@
 PORTANT)
+ %7C%7C%0A                test.equals(PRIORITY_EMPTY)
 ;%0A    %7D%0A
@@ -2222,16 +2222,48 @@
 _NORMAL)
+ %7C%7C value.equals(PRIORITY_EMPTY)
 ) %7B%0A    
@@ -2862,17 +2862,16 @@
 Code();%0A
+
     %7D%0A
-%0A
 %7D%0A

Fix bugs in Priority