private boolean doesCommandExist(String commandName, int arity) { for (ShellCommand cmd : commandTable) { if (cmd.canBeDenotedBy(commandName) && cmd.getArity() == arity) { return true; } } return false; }
public List<ShellCommand> commandsByName(String discriminator) { List<ShellCommand> collectedTable = new ArrayList<ShellCommand>(); // collection for (ShellCommand cs : commandTable) { if (cs.canBeDenotedBy(discriminator)) { collectedTable.add(cs); } } return collectedTable; }