private CommandClosure options(Map<?, ?> options, Object[] arguments) {
CommandClosure ret;
if (this instanceof MethodDispatcher) {
ret = new MethodDispatcher(((MethodDispatcher)this).dispatcher, ((MethodDispatcher)this).name);
} else {
ret = new ClassDispatcher(((ClassDispatcher)this).command, ((ClassDispatcher)this).owner);
}
if (options != null && options.size() > 0) {
if (this.options == null) {
ret.options = new HashMap<String, Object>();
} else {
ret.options = new HashMap<String, Object>(this.options);
}
for (Map.Entry<?, ?> arg : options.entrySet()) {
ret.options.put(arg.getKey().toString(), arg.getValue());
}
}
if (arguments != null) {
ret.args = new ArrayList<Object>(Arrays.asList(arguments));
}
return ret;
}
}