@@ -0,0 +1,2756 @@
+package org.telegram.telegrambots.api.commands;%0A%0Aimport org.telegram.telegrambots.api.objects.Message;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * @author tschulz%0A */%0Apublic final class CommandRegistry implements ICommandRegistery %7B%0A%0A    private final Map%3CString, Command%3E commandRegistryMap = new HashMap%3C%3E();%0A%0A    public CommandRegistry(String botToken) %7B%0A        register(new HelpCommand(this, botToken));%0A    %7D%0A%0A    @Override%0A    public final boolean register(Command command) %7B%0A        if (commandRegistryMap.containsKey(command.getCommandIdentifier())) %7B%0A            return false;%0A        %7D%0A        commandRegistryMap.put(command.getCommandIdentifier(), command);%0A        return true;%0A    %7D%0A%0A    @Override%0A    public final Map%3CCommand, Boolean%3E registerAll(Command... commands) %7B%0A        Map%3CCommand, Boolean%3E resultMap = new HashMap%3C%3E(commands.length);%0A        for (Command command : commands) %7B%0A            resultMap.put(command, register(command));%0A        %7D%0A        return resultMap;%0A    %7D%0A%0A    @Override%0A    public final boolean deregister(Command command) %7B%0A        if (commandRegistryMap.containsKey(command.getCommandIdentifier())) %7B%0A            commandRegistryMap.remove(command.getCommandIdentifier());%0A            return true;%0A        %7D%0A        return false;%0A    %7D%0A%0A    @Override%0A    public final Map%3CCommand, Boolean%3E deregisterAll(Command... commands) %7B%0A        Map%3CCommand, Boolean%3E resultMap = new HashMap%3C%3E(commands.length);%0A        for (Command command : commands) %7B%0A            resultMap.put(command, deregister(command));%0A        %7D%0A        return resultMap;%0A    %7D%0A%0A    @Override%0A    public final Collection%3CCommand%3E getRegisteredCommands() %7B%0A        return commandRegistryMap.values();%0A    %7D%0A%0A    /**%0A     * executes a command if present and replies the success%0A     *%0A     * @param message input message%0A     * @return        true if success or false otherwise%0A     */%0A    public final boolean executeCommand(Message message) %7B%0A        if (message.hasText()) %7B%0A            String text = message.getText();%0A            if (!text.isEmpty() && text.startsWith(Command.COMMAND_INIT_CHARACTER)) %7B%0A                String commandMessage = text.substring(1);%0A                String%5B%5D commandSplit = commandMessage.split(Command.COMMAND_PARAMETER_SEPERATOR);%0A%0A                String command = commandSplit%5B0%5D;%0A%0A                if (commandRegistryMap.containsKey(command)) %7B%0A                    String%5B%5D parameters = Arrays.copyOfRange(commandSplit, 1, commandSplit.length);%0A                    commandRegistryMap.get(command).execute(parameters, message.getChatId());%0A                    return true;%0A                %7D%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%7D

Implement Command Registry