Skip to content

Commit 332dbe0

Browse files
author
shaoxinke
committed
docs: added docs
1 parent 535fa18 commit 332dbe0

File tree

1 file changed

+49
-2
lines changed
  • devkit-utils/src/main/java/com/onixbyte/devkit/utils

1 file changed

+49
-2
lines changed

devkit-utils/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,76 @@
1+
/*
2+
* Copyright (C) 2024-2024 OnixByte.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
*
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package com.onixbyte.devkit.utils;
219

320
import java.util.Arrays;
421
import java.util.Objects;
522
import java.util.function.BooleanSupplier;
623

24+
/**
25+
* A util for boolean calculations.
26+
*
27+
* @author shaoxinke
28+
* @version 1.6.2
29+
*/
730
public final class BoolUtil {
831

32+
/**
33+
* Logical and calculation.
34+
*
35+
* @param values the values to be calculated
36+
* @return {@code true} if all value in values is {@code true}, otherwise {@code false}
37+
*/
938
public static boolean and(Boolean... values) {
1039
return Arrays.stream(values)
1140
.filter(Objects::nonNull)
1241
.allMatch(Boolean::booleanValue);
1342
}
1443

44+
/**
45+
* Logical and calculation.
46+
*
47+
* @param valueSuppliers the suppliers of value to be calculated
48+
* @return {@code true} if all value in values is {@code true}, otherwise {@code false}
49+
*/
1550
public static boolean and(BooleanSupplier... valueSuppliers) {
1651
return Arrays.stream(valueSuppliers)
1752
.filter(Objects::nonNull)
1853
.allMatch(BooleanSupplier::getAsBoolean);
1954
}
2055

21-
public static boolean or(Boolean... valueSuppliers) {
22-
return Arrays.stream(valueSuppliers)
56+
/**
57+
* Logical or calculation.
58+
*
59+
* @param values the values to be calculated
60+
* @return {@code true} if any value in values is {@code true}, otherwise {@code false}
61+
*/
62+
public static boolean or(Boolean... values) {
63+
return Arrays.stream(values)
2364
.filter(Objects::nonNull)
2465
.anyMatch(Boolean::booleanValue);
2566
}
2667

68+
/**
69+
* Logical or calculation.
70+
*
71+
* @param valueSuppliers the suppliers of value to be calculated
72+
* @return {@code true} if any value in values is {@code true}, otherwise {@code false}
73+
*/
2774
public static boolean or(BooleanSupplier... valueSuppliers) {
2875
return Arrays.stream(valueSuppliers)
2976
.filter(Objects::nonNull)

0 commit comments

Comments
 (0)