extract add command code to method addToCommandList()
This commit is contained in:
parent
b8db6f6e19
commit
a5e1dc6d76
2 changed files with 7 additions and 10 deletions
|
@ -67,8 +67,13 @@ public class CommandBuilder {
|
|||
}
|
||||
|
||||
private CommandBuilder addCommand(String name, Object... args){
|
||||
addToCommandList(name, args);
|
||||
Struct struct = prepareStruct(name, args);
|
||||
listStruct.add(struct);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void addToCommandList(String name, Object... args) {
|
||||
listCommands.add(name);
|
||||
for(Object o : args) {
|
||||
if(o != null) {
|
||||
|
@ -77,7 +82,6 @@ public class CommandBuilder {
|
|||
listCommands.add("");
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getListCommands() {
|
||||
|
|
|
@ -55,15 +55,8 @@ public class JSCommandBuilder extends CommandBuilder {
|
|||
}
|
||||
|
||||
private JSCommandBuilder addCommand(String name, Object... args){
|
||||
listCommands.add(name);
|
||||
for(Object o : args) {
|
||||
if(o != null) {
|
||||
listCommands.add(o.toString());
|
||||
} else {
|
||||
listCommands.add("");
|
||||
}
|
||||
}
|
||||
Object obj = jsScope.get(name);
|
||||
addToCommandList(name, args);
|
||||
Object obj = jsScope.get(name);
|
||||
if (obj instanceof Function) {
|
||||
Function jsFunction = (Function) obj;
|
||||
Object jsResult = jsFunction.call(jsContext, jsScope, jsScope, args);
|
||||
|
|
Loading…
Reference in a new issue