package seedu.oneline.model.tag;


import seedu.oneline.commons.exceptions.IllegalValueException;

/**
 * Represents a Tag in the address book.
 * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)}
 */
public class Tag {

    public static final String MESSAGE_TAG_CONSTRAINTS = "Tags names should be alphanumeric";
    public static final String TAG_VALIDATION_REGEX = "\\p{Alnum}+";

    public String tagName;
    private String colour; 

    public Tag() {
    }

    /**
     * Validates given tag name.
     *
     * @throws IllegalValueException if the given tag name string is invalid.
     */
    public Tag(String name) throws IllegalValueException {
        assert name != null;
        name = name.trim();
        if (!isValidTagName(name)) {
            throw new IllegalValueException(MESSAGE_TAG_CONSTRAINTS + " : " + name);
        }
        this.tagName = name;
        this.colour = "#ffffff";
    }

    /**
     * Returns true if a given string is a valid tag name.
     */
    public static boolean isValidTagName(String test) {
        return test.matches(TAG_VALIDATION_REGEX);
    }
    
    public void setColour(String colour) {
        switch(colour) {
        case "white": 
            this.colour = "#ffffff";
            break;
        case "red": 
            this.colour = "#F95E59"; 
            break;
        case "orange": 
            this.colour = "#F95E59"; 
            break;
        case "yellow": 
            this.colour = "#F95E59"; 
            break;
        case "green": 
            this.colour = "#F95E59"; 
            break;
        case "blue": 
            this.colour = "#F95E59"; 
            break;
        case "purple": 
            this.colour = "#F95E59"; 
            break;
        default: 
            return; 
        }
            
    }
    
    public String getColour() {
        return colour; 
    }
    
    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof Tag // instanceof handles nulls
                && this.tagName.equals(((Tag) other).tagName)); // state check
    }

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

    /**
     * Format state as text for viewing.
     */
    public String toString() {
        return '[' + tagName + ']';
    }
    
    /**
     * Serialize field for storage
     */
    public String serialize() {
        return tagName;
    }
    
    /**
     * Deserialize from storage
     */
    public static Tag deserialize(String args) throws IllegalValueException {
        return new Tag(args);
    }

}

@@ -489,24 +489,53 @@
 g() %7B%0A    %7D%0A
+    %0A    //@@author A0142605N
 %0A    /**%0A   
@@ -1436,38 +1436,38 @@
 this.colour = %22#
-F95E59
+ff6633
 %22; %0A            
@@ -1518,37 +1518,37 @@
 his.colour = %22#F
-95E59
+EE715
 %22; %0A            

tag author for collate