package seedu.ezdo.model.todo;

import java.util.ArrayList;

import seedu.ezdo.commons.exceptions.IllegalValueException;

//@@author A0139177W
/**
 * Represents a Task's recurring interval in ezDo.
 * Guarantees: immutable; is valid as declared in {@link #isValidRecurring(String)}
 */
public class Recur {

    public static final String MESSAGE_RECUR_CONSTRAINTS =
            "Recurring time interval should be 'daily', 'weekly', 'monthly' or 'yearly'.";
    public static final String INTERVAL_NONE = "";
    public static final String INTERVAL_DAILY = "daily";
    public static final String INTERVAL_WEEKLY = "weekly";
    public static final String INTERVAL_MONTHLY = "monthly";
    public static final String INTERVAL_YEARLY = "yearly";

    public static final ArrayList<String> RECUR_INTERVALS = new ArrayList<>();

    public final String value;

    /**
     * Validates given recurring time interval.
     *
     * @throws IllegalValueException if given recurring time interval string is invalid.
     */
    public Recur(String recur) throws IllegalValueException {
        initialiseRecurIntervals();
        assert recur != null;
        String trimmedRecur = recur.trim();
        if (!isValidRecur(trimmedRecur)) {
            throw new IllegalValueException(MESSAGE_RECUR_CONSTRAINTS);
        }
        this.value = trimmedRecur;
    }

    private void initialiseRecurIntervals() {
        RECUR_INTERVALS.add(INTERVAL_NONE);
        RECUR_INTERVALS.add(INTERVAL_DAILY);
        RECUR_INTERVALS.add(INTERVAL_WEEKLY);
        RECUR_INTERVALS.add(INTERVAL_MONTHLY);
        RECUR_INTERVALS.add(INTERVAL_YEARLY);
    }

    /**
     * Returns true if a given string is a valid recurring time interval.
     */
    public static boolean isValidRecur(String test) {
        return RECUR_INTERVALS.contains(test);
    }

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

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

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

}

@@ -52,16 +52,69 @@
 rayList;
+%0Aimport java.util.Calendar;%0Aimport java.util.HashMap;
 %0A%0Aimport
@@ -243,19 +243,16 @@
 in ezDo.
-%0A *
  Guarant
@@ -269,16 +269,19 @@
 able; is
+%0A *
  valid a
@@ -412,16 +412,17 @@
 RAINTS =
+ 
 %0A       
@@ -505,16 +505,21 @@
 rly'.%22;%0A
+    %0A
     publ
@@ -826,24 +826,31 @@
 nal 
-ArrayList%3CString
+HashMap%3CString, Integer
 %3E RE
@@ -869,25 +869,23 @@
 S = new 
-ArrayList
+HashMap
 %3C%3E();%0A%0A 
@@ -1014,16 +1014,35 @@
 xception
+%0A     *            
  if give
@@ -1495,35 +1495,35 @@
 RECUR_INTERVALS.
-add
+put
 (INTERVAL_NONE);
@@ -1520,16 +1520,31 @@
 VAL_NONE
+, Calendar.DATE
 );%0A     
@@ -1554,35 +1554,35 @@
 RECUR_INTERVALS.
-add
+put
 (INTERVAL_DAILY)
@@ -1580,16 +1580,39 @@
 AL_DAILY
+, Calendar.DAY_OF_MONTH
 );%0A     
@@ -1622,35 +1622,35 @@
 RECUR_INTERVALS.
-add
+put
 (INTERVAL_WEEKLY
@@ -1649,16 +1649,40 @@
 L_WEEKLY
+, Calendar.WEEK_OF_MONTH
 );%0A     
@@ -1692,35 +1692,35 @@
 RECUR_INTERVALS.
-add
+put
 (INTERVAL_MONTHL
@@ -1720,16 +1720,32 @@
 _MONTHLY
+, Calendar.MONTH
 );%0A     
@@ -1767,11 +1767,11 @@
 ALS.
-add
+put
 (INT
@@ -1782,16 +1782,31 @@
 L_YEARLY
+, Calendar.YEAR
 );%0A    %7D
@@ -1990,16 +1990,19 @@
 contains
+Key
 (test);%0A
@@ -2270,16 +2270,24 @@
 s nulls%0A
+        
         

Replace RECUR_INTERVALS from ArrayList to HashMap