package seedu.address.logic.commands;

import seedu.address.commons.util.TypesUtil;

//@@author A0142325R
/**
 * Lists tasks or events in the task manager to the user.
 */
public class ListCommand extends Command {

    public static final String COMMAND_WORD = "list";
    
    public static final String MESSAGE_USAGE = COMMAND_WORD
            + ": List tasks and events"
            + "Parameters: [type]\n"
            + "Example: "
            + " list, list events, list tasks, list done, list undone";

    public static final String MESSAGE_SUCCESS = "Listed all tasks and events";
    public static final String MESSAGE_EVENT_SUCCESS="Listed all events";
    public static final String MESSAGE_TASK_SUCCESS="Listed all tasks";
    public static final String MESSAGE_LIST_DONE_TASK_SUCCESS="Listed all done tasks or events";
    public static final String MESSAGE_LIST_UNDONE_TASK_SUCCESS="Listed all undone tasks or events";
    
    public static final String MESSAGE_INVALID_LIST_COMMAND = "The list command argument provided is invalid."
            + MESSAGE_USAGE;
    
    private String toList=null;
    
    public ListCommand() {}
    public ListCommand(String typeToList){
    	toList=typeToList.trim();
    }

    @Override
    public CommandResult execute() {
    	if(toList==null){
        model.updateFilteredListToShowAll();
        return new CommandResult(MESSAGE_SUCCESS);
    	}else if(toList.equals(TypesUtil.EVENTS)){
    		model.updateFilteredTaskList(toList);
    		return new CommandResult(MESSAGE_EVENT_SUCCESS);
    	}else if (toList.equals(TypesUtil.TASKS)){
    		model.updateFilteredTaskList(toList);
    		return new CommandResult(MESSAGE_TASK_SUCCESS);
    	}else if (toList.equals(TypesUtil.DONE)) {
    		model.updateFilteredTaskList(toList);
    		return new CommandResult(MESSAGE_LIST_DONE_TASK_SUCCESS);
    	} else if (toList.equals(TypesUtil.UNDONE)) {
    	    model.updateFilteredTaskList(toList);
    	    return new CommandResult(MESSAGE_LIST_UNDONE_TASK_SUCCESS); 
    	} else {
    	    return new CommandResult(MESSAGE_INVALID_LIST_COMMAND);
    	}
    }
}

@@ -36,54 +36,8 @@
 s;%0A%0A
-import seedu.address.commons.util.TypesUtil;%0A%0A
 //@@
@@ -53,16 +53,17 @@
 142325R%0A
+%0A
 /**%0A * L
@@ -162,16 +162,94 @@
 ommand %7B
+%0A    %0A    public enum listType%7B%0A        TASKS,EVENTS,DONE,UNDONE,INVALID%0A    %7D
 %0A%0A    pu
@@ -1123,22 +1123,24 @@
 private 
-String
+listType
  toList=
@@ -1178,16 +1178,21 @@
 nd() %7B%7D%0A
+    %0A
     publ
@@ -1234,34 +1234,184 @@
     
-%09toList=typeToList.trim();
+    try%7B%0A        toList=Enum.valueOf(listType.class,typeToList.trim().toUpperCase());%0A        %7Dcatch(IllegalArgumentException e)%7B%0A            toList=listType.INVALID;%0A        %7D
 %0A   
@@ -1464,22 +1464,36 @@
 cute() %7B
+  
 %0A    
-%09
+    %0A        
 if(toLis
@@ -1502,16 +1502,20 @@
 =null)%7B%0A
+    
         
@@ -1555,24 +1555,28 @@
 ();%0A        
+   
+ 
 return new C
@@ -1614,58 +1614,80 @@
     
-%09%7Delse if(toList.equals(TypesUtil.
+    %7D%0A        %0A        switch(toList)%7B%0A        case 
 EVENTS
-))%7B
+:
 %0A    
-%09%09
+        
 mode
@@ -1713,33 +1713,64 @@
 kList(toList
-);%0A    %09%09
+.toString().toLowerCase());%0A            
 return new C
@@ -1814,58 +1814,36 @@
     
-%09%7Delse if (toList.equals(TypesUtil.
+    case 
 TASKS
-))%7B
+:
 %0A    
-%09%09
+        
 mode
@@ -1869,33 +1869,64 @@
 kList(toList
-);%0A    %09%09
+.toString().toLowerCase());%0A            
 return new C
@@ -1969,102 +1969,110 @@
     
-%09%7Delse if (toList.equals(TypesUtil.DONE)) %7B%0A    %09%09model.updateFilteredTaskList(toList);%0A    %09%09
+    case DONE:%0A            model.updateFilteredTaskList(toList.toString().toLowerCase());%0A            
 retu
@@ -2133,60 +2133,33 @@
     
-%09%7D else if (toList.equals(TypesUtil.
+    case 
 UNDONE
-)) %7B
+:
 %0A    
-%09
+    
     
@@ -2193,24 +2193,52 @@
 t(toList
+.toString().toLowerCase()
 );%0A    
-%09
+    
     retu
@@ -2296,29 +2296,34 @@
 SS);
- 
 %0A    
-%09%7D else %7B
+    default:
 %0A    
-%09
+    
     
@@ -2386,10 +2386,22 @@
     
-%09%7D
+    %7D%0A        
 %0A   

resolve conflict