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){
|
private CommandBuilder addCommand(String name, Object... args){
|
||||||
|
addToCommandList(name, args);
|
||||||
Struct struct = prepareStruct(name, args);
|
Struct struct = prepareStruct(name, args);
|
||||||
listStruct.add(struct);
|
listStruct.add(struct);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addToCommandList(String name, Object... args) {
|
||||||
listCommands.add(name);
|
listCommands.add(name);
|
||||||
for(Object o : args) {
|
for(Object o : args) {
|
||||||
if(o != null) {
|
if(o != null) {
|
||||||
|
@ -77,7 +82,6 @@ public class CommandBuilder {
|
||||||
listCommands.add("");
|
listCommands.add("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getListCommands() {
|
public List<String> getListCommands() {
|
||||||
|
|
|
@ -55,15 +55,8 @@ public class JSCommandBuilder extends CommandBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSCommandBuilder addCommand(String name, Object... args){
|
private JSCommandBuilder addCommand(String name, Object... args){
|
||||||
listCommands.add(name);
|
addToCommandList(name, args);
|
||||||
for(Object o : args) {
|
Object obj = jsScope.get(name);
|
||||||
if(o != null) {
|
|
||||||
listCommands.add(o.toString());
|
|
||||||
} else {
|
|
||||||
listCommands.add("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Object obj = jsScope.get(name);
|
|
||||||
if (obj instanceof Function) {
|
if (obj instanceof Function) {
|
||||||
Function jsFunction = (Function) obj;
|
Function jsFunction = (Function) obj;
|
||||||
Object jsResult = jsFunction.call(jsContext, jsScope, jsScope, args);
|
Object jsResult = jsFunction.call(jsContext, jsScope, jsScope, args);
|
||||||
|
|
Loading…
Reference in a new issue