allow more than 2 AND and OR conditions
This commit is contained in:
parent
6b1f370e9b
commit
ef4e039998
@ -46,7 +46,7 @@ public class And implements Function {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object call(Properties bindings, Object[] args) {
|
public Object call(Properties bindings, Object[] args) {
|
||||||
if (args.length == 2 && args[0] instanceof Boolean && args[1] instanceof Boolean) {
|
if (args.length >= 2 && args[0] instanceof Boolean && args[1] instanceof Boolean) {
|
||||||
for (Object o : args) {
|
for (Object o : args) {
|
||||||
if (!Not.objectToBoolean(o)) {
|
if (!Not.objectToBoolean(o)) {
|
||||||
return false;
|
return false;
|
||||||
@ -54,7 +54,7 @@ public class And implements Function {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two booleans");
|
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two or more booleans");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,7 +62,7 @@ public class And implements Function {
|
|||||||
throws JSONException {
|
throws JSONException {
|
||||||
|
|
||||||
writer.object();
|
writer.object();
|
||||||
writer.key("description"); writer.value("ANDs two boolean values");
|
writer.key("description"); writer.value("AND two or more booleans to yield a boolean");
|
||||||
writer.key("params"); writer.value("boolean a, boolean b");
|
writer.key("params"); writer.value("boolean a, boolean b");
|
||||||
writer.key("returns"); writer.value("boolean");
|
writer.key("returns"); writer.value("boolean");
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
|
@ -46,7 +46,7 @@ public class Or implements Function {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object call(Properties bindings, Object[] args) {
|
public Object call(Properties bindings, Object[] args) {
|
||||||
if (args.length == 2 && args[0] instanceof Boolean && args[1] instanceof Boolean) {
|
if (args.length >= 2 && args[0] instanceof Boolean && args[1] instanceof Boolean) {
|
||||||
for (Object o : args) {
|
for (Object o : args) {
|
||||||
if (Not.objectToBoolean(o)) {
|
if (Not.objectToBoolean(o)) {
|
||||||
return true;
|
return true;
|
||||||
@ -54,7 +54,7 @@ public class Or implements Function {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two booleans");
|
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two or more booleans");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,7 +62,7 @@ public class Or implements Function {
|
|||||||
throws JSONException {
|
throws JSONException {
|
||||||
|
|
||||||
writer.object();
|
writer.object();
|
||||||
writer.key("description"); writer.value("Returns a OR b");
|
writer.key("description"); writer.value("OR two or more booleans to yield a boolean");
|
||||||
writer.key("params"); writer.value("boolean a, boolean b");
|
writer.key("params"); writer.value("boolean a, boolean b");
|
||||||
writer.key("returns"); writer.value("boolean");
|
writer.key("returns"); writer.value("boolean");
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
|
Loading…
Reference in New Issue
Block a user