<commit_before>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]);
    }
}<commit_msg>Check if old and new category names are the same::RenameCategoryCommandParser<commit_after>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.";
    private static final String ERROR_SAME_FIELDS = "Warning: old and new category names are the same.";

    public Command parse(String args) {
        String[] categories = ParserUtil.parseRenameCategory(args);
        String oldCategory = categories[INDEX_OLD_CATEGORY];
        String newCategory = categories[INDEX_NEW_CATEGORY];

        if (categories.length != NUM_CATEGORIES_PARAM) {
            return new IncorrectCommand(
                    String.format(MESSAGE_INVALID_COMMAND_FORMAT, RenameCategoryCommand.MESSAGE_USAGE));
        } else if (!oldCategory.matches(FORMAT_ALPHANUMERIC) ||
            !newCategory.matches(FORMAT_ALPHANUMERIC)) {
            return new IncorrectCommand(
                    String.format(MESSAGE_INVALID_COMMAND_FORMAT, ERROR_NON_ALPHANUMERIC));
        } else if (oldCategory.equals(newCategory)) {
            return new IncorrectCommand(ERROR_SAME_FIELDS);
        }

        return new RenameCategoryCommand(oldCategory, newCategory);
    }
}
{'fraction_non_alphanumeric': 0.07510255601136005, 'fraction_numerical': 0.003155569580309246, 'mean_word_length': 3.9453978159126364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4825947', 'n_tokens_mistral': 950, 'n_tokens_neox': 926, 'n_words': 187}