style: reduce redundant codes

This commit is contained in:
zihluwang
2024-08-22 21:38:06 +08:00
parent 578d77d5d3
commit 21aa2e2221
@@ -89,62 +89,50 @@ public final class BranchUtil<T> {
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation on the provided
* boolean expressions.
*
* @param booleans the boolean expressions to be evaluated
* @param values the boolean expressions to be evaluated
* @param <T> the type of the result to be handled by the methods
* @return a {@code BranchUtil} instance representing the result of the logical OR operation
*/
public static <T> BranchUtil<T> or(Boolean... booleans) {
var result = Arrays.stream(booleans)
.filter(Objects::nonNull)
.anyMatch(Boolean::booleanValue);
return new BranchUtil<>(result);
public static <T> BranchUtil<T> or(Boolean... values) {
return new BranchUtil<>(BoolUtil.or(values));
}
/**
* Creates a {@code BranchUtil} instance to evaluate a logical AND operation on the provided
* boolean expressions.
*
* @param booleans the boolean expressions to be evaluated
* @param values the boolean expressions to be evaluated
* @param <T> the type of the result to be handled by the methods
* @return a {@code BranchUtil} instance representing the result of the logical AND operation
*/
public static <T> BranchUtil<T> and(Boolean... booleans) {
var result = Arrays.stream(booleans)
.filter(Objects::nonNull)
.allMatch(Boolean::booleanValue);
return new BranchUtil<>(result);
public static <T> BranchUtil<T> and(Boolean... values) {
return new BranchUtil<>(BoolUtil.and(values));
}
/**
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation on the provided
* boolean suppliers.
*
* @param booleanSuppliers the boolean suppliers to be evaluated
* @param valueSuppliers the boolean suppliers to be evaluated
* @param <T> the type of the result to be handled by the methods
* @return a {@code BranchUtil} instance representing the result of the
* logical OR operation
*/
public static <T> BranchUtil<T> or(BooleanSupplier... booleanSuppliers) {
var result = Arrays.stream(booleanSuppliers)
.filter(Objects::nonNull)
.anyMatch(BooleanSupplier::getAsBoolean);
return new BranchUtil<>(result);
public static <T> BranchUtil<T> or(BooleanSupplier... valueSuppliers) {
return new BranchUtil<>(BoolUtil.or(valueSuppliers));
}
/**
* Creates a {@code BranchUtil} instance to evaluate a logical AND operation on the provided
* boolean suppliers.
*
* @param booleanSuppliers the boolean suppliers to be evaluated
* @param valueSuppliers the boolean suppliers to be evaluated
* @param <T> the type of the result to be handled by the methods
* @return a {@code BranchUtil} instance representing the result of the
* logical AND operation
*/
public static <T> BranchUtil<T> and(BooleanSupplier... booleanSuppliers) {
var result = Arrays.stream(booleanSuppliers)
.filter(Objects::nonNull)
.allMatch(BooleanSupplier::getAsBoolean);
return new BranchUtil<>(result);
public static <T> BranchUtil<T> and(BooleanSupplier... valueSuppliers) {
return new BranchUtil<>(BoolUtil.and(valueSuppliers));
}
/**