|
@@ -0,0 +1,54 @@
|
|
|
|
+package cn.com.qmth.examcloud.commons.util;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.lang3.BooleanUtils;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * boolean 工具
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @date 2019年10月21日
|
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
|
+ */
|
|
|
|
+public class BooleanUtil {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 统计true的数量
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @param values
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static int countTrue(boolean... values) {
|
|
|
|
+ if (null == values) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (boolean b : values) {
|
|
|
|
+ if (BooleanUtils.isTrue(b)) {
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return count;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 统计false的数量
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @param values
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static int countFalse(boolean... values) {
|
|
|
|
+ if (null == values) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (boolean b : values) {
|
|
|
|
+ if (BooleanUtils.isFalse(b)) {
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return count;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|