package seedu.taskboss.logic.parser;

import static seedu.taskboss.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.taskboss.logic.commands.Command;
import seedu.taskboss.logic.commands.IncorrectCommand;
import seedu.taskboss.logic.commands.RenameCategoryCommand;

public class RenameCategoryCommandParser {

    private static final int NUM_CATEGORIES_PARAM = 2;
    private static final int INDEX_OLD_CATEGORY = 0;
    private static final int INDEX_NEW_CATEGORY = 1;
    private static final String FORMAT_ALPHANUMERIC = "[A-Za-z0-9]+";
    private static final String ERROR_NON_ALPHANUMERIC = "Category names should be alphanumeric.";

    public Command parse(String args) {
        String[] categories = ParserUtil.parseRenameCategory(args);
        if (categories.length != NUM_CATEGORIES_PARAM) {
            return new IncorrectCommand(
                    String.format(MESSAGE_INVALID_COMMAND_FORMAT, RenameCategoryCommand.MESSAGE_USAGE));
        } else if (!categories[INDEX_OLD_CATEGORY].matches(FORMAT_ALPHANUMERIC) ||
            !categories[INDEX_NEW_CATEGORY].matches(FORMAT_ALPHANUMERIC)) {
            return new IncorrectCommand(
                    String.format(MESSAGE_INVALID_COMMAND_FORMAT, ERROR_NON_ALPHANUMERIC));
        } 

        
        return new RenameCategoryCommand(categories[INDEX_OLD_CATEGORY], categories[INDEX_NEW_CATEGORY]);
    }
}

@@ -376,16 +376,17 @@
 AM = 2;%0A
+%0A
     priv
@@ -483,16 +483,17 @@
 RY = 1;%0A
+%0A
     priv
@@ -554,16 +554,17 @@
 0-9%5D+%22;%0A
+%0A
     priv
@@ -653,16 +653,121 @@
 meric.%22;
+%0A    private static final String ERROR_SAME_FIELDS = %22Warning: old and new category names are the same.%22;
 %0A%0A    pu
@@ -868,16 +868,139 @@
 (args);%0A
+        String oldCategory = categories%5BINDEX_OLD_CATEGORY%5D;%0A        String newCategory = categories%5BINDEX_NEW_CATEGORY%5D;%0A%0A
         
@@ -1218,38 +1218,19 @@
 f (!
-c
+oldC
 ategor
-ies%5BINDEX_OLD_CATEGORY%5D
+y
 .mat
@@ -1275,38 +1275,19 @@
    !
-c
+newC
 ategor
-ies%5BINDEX_NEW_CATEGORY%5D
+y
 .mat
@@ -1458,17 +1458,119 @@
       %7D 
-%0A
+else if (oldCategory.equals(newCategory)) %7B%0A            return new IncorrectCommand(ERROR_SAME_FIELDS);
 %0A       
@@ -1570,16 +1570,18 @@
         
+%7D%0A
 %0A       
@@ -1618,70 +1618,32 @@
 and(
-c
+oldC
 ategor
-ies%5BINDEX_OLD_CATEGORY%5D, categories%5BINDEX_NEW_CATEGORY%5D
+y, newCategory
 );%0A 

Check if old and new category names are the same::RenameCategoryCommandParser