Skip to content

Commit 21aa2e2

Browse files
author
zihluwang
committed
style: reduce redundant codes
1 parent 578d77d commit 21aa2e2

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

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

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,62 +89,50 @@ private BranchUtil(boolean result) {
8989
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation on the provided
9090
* boolean expressions.
9191
*
92-
* @param booleans the boolean expressions to be evaluated
93-
* @param <T> the type of the result to be handled by the methods
92+
* @param values the boolean expressions to be evaluated
93+
* @param <T> the type of the result to be handled by the methods
9494
* @return a {@code BranchUtil} instance representing the result of the logical OR operation
9595
*/
96-
public static <T> BranchUtil<T> or(Boolean... booleans) {
97-
var result = Arrays.stream(booleans)
98-
.filter(Objects::nonNull)
99-
.anyMatch(Boolean::booleanValue);
100-
return new BranchUtil<>(result);
96+
public static <T> BranchUtil<T> or(Boolean... values) {
97+
return new BranchUtil<>(BoolUtil.or(values));
10198
}
10299

103100
/**
104101
* Creates a {@code BranchUtil} instance to evaluate a logical AND operation on the provided
105102
* boolean expressions.
106103
*
107-
* @param booleans the boolean expressions to be evaluated
108-
* @param <T> the type of the result to be handled by the methods
104+
* @param values the boolean expressions to be evaluated
105+
* @param <T> the type of the result to be handled by the methods
109106
* @return a {@code BranchUtil} instance representing the result of the logical AND operation
110107
*/
111-
public static <T> BranchUtil<T> and(Boolean... booleans) {
112-
var result = Arrays.stream(booleans)
113-
.filter(Objects::nonNull)
114-
.allMatch(Boolean::booleanValue);
115-
return new BranchUtil<>(result);
108+
public static <T> BranchUtil<T> and(Boolean... values) {
109+
return new BranchUtil<>(BoolUtil.and(values));
116110
}
117111

118112
/**
119113
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation on the provided
120114
* boolean suppliers.
121115
*
122-
* @param booleanSuppliers the boolean suppliers to be evaluated
123-
* @param <T> the type of the result to be handled by the methods
116+
* @param valueSuppliers the boolean suppliers to be evaluated
117+
* @param <T> the type of the result to be handled by the methods
124118
* @return a {@code BranchUtil} instance representing the result of the
125119
* logical OR operation
126120
*/
127-
public static <T> BranchUtil<T> or(BooleanSupplier... booleanSuppliers) {
128-
var result = Arrays.stream(booleanSuppliers)
129-
.filter(Objects::nonNull)
130-
.anyMatch(BooleanSupplier::getAsBoolean);
131-
return new BranchUtil<>(result);
121+
public static <T> BranchUtil<T> or(BooleanSupplier... valueSuppliers) {
122+
return new BranchUtil<>(BoolUtil.or(valueSuppliers));
132123
}
133124

134125
/**
135126
* Creates a {@code BranchUtil} instance to evaluate a logical AND operation on the provided
136127
* boolean suppliers.
137128
*
138-
* @param booleanSuppliers the boolean suppliers to be evaluated
139-
* @param <T> the type of the result to be handled by the methods
129+
* @param valueSuppliers the boolean suppliers to be evaluated
130+
* @param <T> the type of the result to be handled by the methods
140131
* @return a {@code BranchUtil} instance representing the result of the
141132
* logical AND operation
142133
*/
143-
public static <T> BranchUtil<T> and(BooleanSupplier... booleanSuppliers) {
144-
var result = Arrays.stream(booleanSuppliers)
145-
.filter(Objects::nonNull)
146-
.allMatch(BooleanSupplier::getAsBoolean);
147-
return new BranchUtil<>(result);
134+
public static <T> BranchUtil<T> and(BooleanSupplier... valueSuppliers) {
135+
return new BranchUtil<>(BoolUtil.and(valueSuppliers));
148136
}
149137

150138
/**

0 commit comments

Comments
 (0)