//@@author A0141052Y
package seedu.task.logic.parser;

import java.util.HashMap;
import java.util.Optional;
import java.util.logging.Logger;

import seedu.task.commons.core.LogsCenter;

/**
 * Provides command word and alias mappings
 * @author Syed Abdullah
 *
 */
public class ParserMapping {
    HashMap<String, Class<? extends BaseParser>> mappingTable = new HashMap<>();
    private final Logger logger = LogsCenter.getLogger(ParserMapping.class);
    
    public ParserMapping() {
        populateMappings();
    }
    
    /**
     * Populates the command word to command parsers mapping table
     */
    private void populateMappings() {
        mappingTable.put("add", AddParser.class);
        mappingTable.put("alias", AliasParser.class);
        mappingTable.put("clear", ClearParser.class);
        mappingTable.put("complete", CompleteParser.class);
        mappingTable.put("change-to", ChangePathParser.class);
        mappingTable.put("delete", DeleteParser.class);
        mappingTable.put("exit", ExitParser.class);
        mappingTable.put("find", FindParser.class);
        mappingTable.put("help", HelpParser.class);
        mappingTable.put("list", ListParser.class);
        mappingTable.put("pin", PinParser.class);
        mappingTable.put("searchbox", SearchParser.class);
        mappingTable.put("select", SelectParser.class);
        mappingTable.put("undo", UndoParser.class);
        mappingTable.put("update", UpdateParser.class);
        mappingTable.put("uncomplete", UncompleteParser.class);
        mappingTable.put("unpin", UnpinParser.class);
    }

    /**
     * Retrieves commands for a specified keyword
     * @param commandWord
     * @return
     */
    public Optional<Class<? extends BaseParser>> getParserForCommand(String commandWord) {
        if (mappingTable.containsKey(commandWord) && mappingTable.get(commandWord) != null) {
            return Optional.of(mappingTable.get(commandWord));
        } else {
            logger.info("[USER COMMAND][" + commandWord + "] not found!");
            return Optional.empty();
        }
    }
}
@@ -177,16 +177,70 @@
 sCenter;
+%0Aimport seedu.task.commons.logic.CommandKeys.Commands;
 %0A%0A/**%0A *
@@ -354,22 +354,24 @@
 HashMap%3C
-String
+Commands
 , Class%3C
@@ -511,71 +511,8 @@
    %0A
-    public ParserMapping() %7B%0A        populateMappings();%0A    %7D%0A
     
@@ -662,13 +662,20 @@
 put(
-%22add%22
+Commands.ADD
 , Ad
@@ -719,15 +719,22 @@
 put(
-%22alias%22
+Commands.ALIAS
 , Al
@@ -780,15 +780,22 @@
 put(
-%22clear%22
+Commands.CLEAR
 , Cl
@@ -841,18 +841,25 @@
 put(
-%22complete%22
+Commands.COMPLETE
 , Co
@@ -908,19 +908,26 @@
 put(
-%22change-to%22
+Commands.CHANGE_TO
 , Ch
@@ -978,16 +978,23 @@
 put(
-%22delete%22
+Commands.DELETE
 , De
@@ -1041,14 +1041,21 @@
 put(
-%22exit%22
+Commands.EXIT
 , Ex
@@ -1100,14 +1100,21 @@
 put(
-%22find%22
+Commands.FIND
 , Fi
@@ -1159,14 +1159,21 @@
 put(
-%22help%22
+Commands.HELP
 , He
@@ -1218,14 +1218,21 @@
 put(
-%22list%22
+Commands.LIST
 , Li
@@ -1277,13 +1277,20 @@
 put(
-%22pin%22
+Commands.PIN
 , Pi
@@ -1334,19 +1334,27 @@
 put(
-%22searchbox%22
+Commands.SEARCH_BOX
 , Se
@@ -1401,16 +1401,23 @@
 put(
-%22select%22
+Commands.SELECT
 , Se
@@ -1464,14 +1464,21 @@
 put(
-%22undo%22
+Commands.UNDO
 , Un
@@ -1523,16 +1523,23 @@
 put(
-%22update%22
+Commands.UPDATE
 , Up
@@ -1586,20 +1586,27 @@
 put(
-%22uncomplete%22
+Commands.UNCOMPLETE
 , Un
@@ -1657,15 +1657,22 @@
 put(
-%22unpin%22
+Commands.UNPIN
 , Un
@@ -1890,24 +1890,59 @@
 mandWord) %7B%0A
+        //go through alias hashmap%0A
         if (
@@ -1966,27 +1966,16 @@
 ainsKey(
-commandWord
 ) && map
@@ -1988,27 +1988,16 @@
 ble.get(
-commandWord
 ) != nul

Change parser mapping