package bjc.utils.cli; /** * A class for a command that delegates to another command. * * @author ben * */ class DelegatingCommand implements ICommand { /* * The command to delegate to. */ private ICommand delegate; /** * Create a new command that delegates to another command. * * @param delegate * The command to delegate to. */ public DelegatingCommand(ICommand delegate) { this.delegate = delegate; } @Override public ICommand aliased() { return new DelegatingCommand(delegate); } @Override public ICommandHandler getHandler() { return delegate.getHandler(); } @Override public ICommandHelp getHelp() { return delegate.getHelp(); } @Override public boolean isAlias() { return true; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("DelegatingCommand ["); if(delegate != null) { builder.append("delegate="); builder.append(delegate); } builder.append("]"); return builder.toString(); } }