package com.juick.command; import com.juick.User; import java.util.regex.Matcher; /** * @author ma1uta */ public abstract class MultiArgsCommand implements Command { @Override public String execute(User sender, MessageListener protocolListener, String command) { Matcher matcher = pattern().matcher(command.trim()); String[] arguments = new String[matcher.groupCount()]; for (int i = 1; i <= matcher.groupCount(); i++) { arguments[i - 1] = (matcher.group(i)); } return execute(sender, protocolListener, arguments); } protected abstract String execute(User sender, MessageListener protocolListener, String... arguments); }