Skip to content

Commit 535fa18

Browse files
author
shaoxinke
committed
Merge branch 'feature/boolean-util' into release/1.6.2
2 parents 9bac26b + 48f1230 commit 535fa18

File tree

1 file changed

+33
-0
lines changed
  • devkit-utils/src/main/java/com/onixbyte/devkit/utils

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.onixbyte.devkit.utils;
2+
3+
import java.util.Arrays;
4+
import java.util.Objects;
5+
import java.util.function.BooleanSupplier;
6+
7+
public final class BoolUtil {
8+
9+
public static boolean and(Boolean... values) {
10+
return Arrays.stream(values)
11+
.filter(Objects::nonNull)
12+
.allMatch(Boolean::booleanValue);
13+
}
14+
15+
public static boolean and(BooleanSupplier... valueSuppliers) {
16+
return Arrays.stream(valueSuppliers)
17+
.filter(Objects::nonNull)
18+
.allMatch(BooleanSupplier::getAsBoolean);
19+
}
20+
21+
public static boolean or(Boolean... valueSuppliers) {
22+
return Arrays.stream(valueSuppliers)
23+
.filter(Objects::nonNull)
24+
.anyMatch(Boolean::booleanValue);
25+
}
26+
27+
public static boolean or(BooleanSupplier... valueSuppliers) {
28+
return Arrays.stream(valueSuppliers)
29+
.filter(Objects::nonNull)
30+
.anyMatch(BooleanSupplier::getAsBoolean);
31+
}
32+
33+
}

0 commit comments

Comments
 (0)