package seedu.taskboss.model.task;

import seedu.taskboss.commons.exceptions.IllegalValueException;

//@@author A0144904H
/**
 * Represents a Task's priority level in TaskBoss.
 * Guarantees: immutable; is valid as declared in {@link #isValidPriorityLevel(String)}
 */
public class PriorityLevel {

    private static final String STRING_YES = "Yes";
    private static final String STRING_NO = "No";

    private static final String EMPTY_STRING = "";

    public static final String MESSAGE_PRIORITY_CONSTRAINTS = "Task priority level should only contain"
            + " the words Yes and No (case-insensitive) or the letters y(Y) and n(N)";

    public static final String PRIORITY_HIGH_VALUE = "High priority";
    public static final String PRIORITY_NO_VALUE = "No priority";
    public static final String PRIORITY_REGEX = "^(?:Yes|No|yes|YES|NO|no|y|n|Y|N|yEs"
            + "|yeS|nO|YEs|yES|YeS)$";

    public String value;
    public String input;

    /**
     * Validates given priority level.
     *
     * @throws IllegalValueException if given priority level string is invalid.
     */
    public PriorityLevel(String priorityLevel) throws IllegalValueException {
        assert priorityLevel != null;

        this.value = PRIORITY_NO_VALUE;;
        this.input = STRING_NO;
        String trimmedPriorityLevel = priorityLevel.trim();

        if (!isValidPriorityLevel(trimmedPriorityLevel)) {
            throw new IllegalValueException(MESSAGE_PRIORITY_CONSTRAINTS);
        }

        if (trimmedPriorityLevel.contains("y") || trimmedPriorityLevel.contains("Y")) {
            this.value = PRIORITY_HIGH_VALUE;
            this.input = STRING_YES;
        }
}

/**
 * Returns true if a given string is a valid task priority level.
 */
public static boolean isValidPriorityLevel(String test) {
    return test.matches(PRIORITY_REGEX) ||
            EMPTY_STRING.equals(test);
}

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

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

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

}

@@ -1676,15 +1676,27 @@
   %7D%0A
-%7D%0A%0A
+    %7D%0A%0A    
 /**%0A
+    
  * R
@@ -1758,19 +1758,27 @@
 level.%0A 
-*/%0A
+    */%0A    
 public s
@@ -1827,24 +1827,28 @@
 test) %7B%0A    
+  
+  
 return test.
@@ -1886,16 +1886,20 @@
         
+    
 EMPTY_ST
@@ -1917,19 +1917,27 @@
 (test);%0A
-%7D%0A%0A
+    %7D%0A%0A    
 @Overrid
@@ -1934,24 +1934,28 @@
   @Override%0A
+    
 public Strin
@@ -1965,24 +1965,28 @@
 oString() %7B%0A
+    
     return v
@@ -1991,19 +1991,27 @@
  value;%0A
-%7D%0A%0A
+    %7D%0A%0A    
 @Overrid
@@ -2008,24 +2008,28 @@
   @Override%0A
+    
 public boole
@@ -2050,24 +2050,28 @@
 ct other) %7B%0A
+    
     return o
@@ -2127,16 +2127,20 @@
         
+ 
+   
 %7C%7C (othe
@@ -2214,16 +2214,20 @@
         
+  
+  
 && this.
@@ -2287,19 +2287,27 @@
 e check%0A
-%7D%0A%0A
+    %7D%0A%0A    
 @Overrid
@@ -2308,16 +2308,20 @@
 verride%0A
+    
 public i
@@ -2336,24 +2336,28 @@
 ode() %7B%0A    
+   
+ 
 return value
@@ -2369,13 +2369,17 @@
 Code();%0A
+    
 %7D%0A%0A%7D%0A

fix travis