diff --git a/fizz-core/src/main/java/we/fizz/function/CommonFunc.java b/fizz-core/src/main/java/we/fizz/function/CommonFunc.java
index 6c36314..6ce5e21 100644
--- a/fizz-core/src/main/java/we/fizz/function/CommonFunc.java
+++ b/fizz-core/src/main/java/we/fizz/function/CommonFunc.java
@@ -62,6 +62,9 @@ public class CommonFunc implements IFunc {
FuncExecutor.register(NAME_SPACE_PREFIX + "common.isNotBlank", this);
FuncExecutor.register(NAME_SPACE_PREFIX + "common.isEmpty", this);
FuncExecutor.register(NAME_SPACE_PREFIX + "common.isNotEmpty", this);
+ FuncExecutor.register(NAME_SPACE_PREFIX + "common.and", this);
+ FuncExecutor.register(NAME_SPACE_PREFIX + "common.or", this);
+ FuncExecutor.register(NAME_SPACE_PREFIX + "common.not", this);
}
/**
@@ -132,4 +135,43 @@ public class CommonFunc implements IFunc {
return !isEmpty(obj);
}
+ /**
+ * Return true if all args are true
+ *
+ * @param objs
+ * @return
+ */
+ public boolean and(Boolean... objs) {
+ if (objs != null && objs.length > 0) {
+ for (int i = 0; i < objs.length; i++) {
+ if (objs[i] == null || !objs[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true if any arg is true
+ *
+ * @param objs
+ * @return
+ */
+ public boolean or(Boolean... objs) {
+ if (objs != null && objs.length > 0) {
+ for (int i = 0; i < objs.length; i++) {
+ if (objs[i] != null && objs[i]) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean not(Boolean obj) {
+ return !(obj == null ? false : obj);
+ }
+
}
diff --git a/fizz-core/src/test/java/we/fizz/function/CommonFuncTests.java b/fizz-core/src/test/java/we/fizz/function/CommonFuncTests.java
index 0c1a423..93c8040 100644
--- a/fizz-core/src/test/java/we/fizz/function/CommonFuncTests.java
+++ b/fizz-core/src/test/java/we/fizz/function/CommonFuncTests.java
@@ -52,6 +52,18 @@ class CommonFuncTests {
m.put("a", "1");
m.put("b", "1");
m.put("d", "");
+ m.put("true", true);
+ m.put("false", false);
+ m.put("blank", "");
+ m.put("null", null);
+ m.put("stringtrue", "true");
+ m.put("stringfalse", "false");
+ m.put("string1", "1");
+ m.put("string0", "0");
+ m.put("stringabc", "abc");
+ m.put("int1", "1");
+ m.put("int0", "0");
+ m.put("int2", "2");
List