package seedu.jimi.model.event;

import java.util.Objects;

import seedu.jimi.commons.util.CollectionUtil;
import seedu.jimi.model.datetime.DateTime;
import seedu.jimi.model.tag.UniqueTagList;
import seedu.jimi.model.task.Name;
import seedu.jimi.model.task.ReadOnlyTask;

public class Event implements ReadOnlyTask {

    private Name name;
    private DateTime start;
    private DateTime end;
    private UniqueTagList tags;
    private boolean isCompleted;
    
    public Event(Name name, DateTime start, DateTime end, UniqueTagList tags, boolean isCompleted) {
        this(name, start, end, tags);
        this.isCompleted = isCompleted;
    }
    
    public Event(Name name, DateTime start, DateTime end, UniqueTagList tags) {
        assert !CollectionUtil.isAnyNull(name, start, end, tags);
        assert start.compareTo(end) <= 0;
        this.isCompleted = false;
        this.name = name;
        this.start = start;
        this.end = end;
        this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list
    }
    
    /**
     * Copy constructor.
     */
    public Event(Event source) {
        this(source.getName(), ((Event) source).getStart(), ((Event) source).getEnd(), source.getTags(),
                source.isCompleted());
    }
    
    
    @Override
    public Name getName() {
        return name;
    }
    
    public DateTime getStart() {
        return start;
    }
    
    public DateTime getEnd() {
        return end;
    }

    @Override
    public boolean isCompleted() {
        return isCompleted;
    }
    
    public void setCompleted(boolean c) {
        isCompleted = c;
    }

    @Override
    public UniqueTagList getTags() {
        return new UniqueTagList(tags);
    }

    @Override
    public void setTags(UniqueTagList replacement) {
        tags.setTags(replacement);
    }

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

    @Override
    public boolean isSameStateAs(ReadOnlyTask other) {
        return other == this // short circuit if same object
                || (other instanceof Event // instanceof handles nulls
                    && (other).getName().equals(this.getName()) // state checks here onwards
                    && (other).isCompleted() == this.isCompleted()
                    && ((Event)other).getStart().equals(this.getStart())
                    && ((Event)other).getEnd().equals(this.getEnd())
                );
    }
    
    @Override
    public int hashCode() {
        // use this method for custom fields hashing instead of implementing your own
        return Objects.hash(name, start, end, tags);
    }

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

    @Override
    public String getAsText() {
        final StringBuilder builder = new StringBuilder();
        builder.append(getName())
               .append(" Start: ")
               .append(getStart())
               .append(" End: ")
               .append(getEnd() == null ? "none" : getEnd())
               .append(" Tags: ");
        getTags().forEach(builder::append);
        return builder.toString();
    }


}

@@ -139,24 +139,62 @@
 e.DateTime;%0A
+import seedu.jimi.model.tag.Priority;%0A
 import seedu
@@ -487,24 +487,55 @@
 sCompleted;%0A
+    private Priority priority;%0A
     %0A    pub
@@ -624,16 +624,35 @@
 ompleted
+, Priority priority
 ) %7B%0A    
@@ -674,32 +674,42 @@
 start, end, tags
+, priority
 );%0A        this.
@@ -822,16 +822,35 @@
 ist tags
+, Priority priority
 ) %7B%0A    
@@ -1164,16 +1164,50 @@
 rg list%0A
+        this.priority = priority;%0A
     %7D%0A  
@@ -1424,16 +1424,38 @@
 pleted()
+, source.getPriority()
 );%0A    %7D
@@ -1913,32 +1913,120 @@
 ist(tags);%0A    %7D
+%0A    %0A    @Override%0A    public Priority getPriority()   %7B%0A        return priority;%0A    %7D
 %0A%0A    @Override%0A
@@ -3567,16 +3567,93 @@
 ppend);%0A
+        builder.append(%22 Priority: %22)%0A               .append(getPriority());%0A
         

Implement Priority in Event