Browse Source

性能优化

woody 3 months ago
parent
commit
7ec8180923

+ 5 - 5
framework-common/src/main/java/com/chelvc/framework/common/util/ChineseUtils.java

@@ -8,7 +8,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.Map;
 import java.util.Set;
-import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.regex.Matcher;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -268,10 +268,10 @@ public final class ChineseUtils {
      * 获取文本中的所有数字
      *
      * @param text   文本信息
-     * @param filter 数字过滤方法
+     * @param filter 数字过滤函数
      * @return 数字集合
      */
-    public static Set<Long> numbers(String text, @NonNull Function<Long, Boolean> filter) {
+    public static Set<Long> numbers(String text, @NonNull Predicate<Long> filter) {
         if (StringUtils.isEmpty(text)) {
             return Collections.emptySet();
         }
@@ -279,11 +279,11 @@ public final class ChineseUtils {
         Matcher matcher = StringUtils.getPattern(NUMBER_REGEX).matcher(text);
         while (matcher.find()) {
             Long number = string2number(matcher.group());
-            if (number != null && Boolean.TRUE.equals(filter.apply(number))) {
+            if (number != null && filter.test(number)) {
                 numbers.add(number);
             }
         }
-        return numbers;
+        return numbers.isEmpty() ? Collections.emptySet() : numbers;
     }
 
     /**

+ 33 - 26
framework-common/src/main/java/com/chelvc/framework/common/util/ObjectUtils.java

@@ -23,9 +23,10 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
 import java.util.function.Consumer;
 import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -35,7 +36,6 @@ import com.chelvc.framework.common.function.Setter;
 import com.chelvc.framework.common.model.Modification;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 import io.protostuff.LinkedBuffer;
 import io.protostuff.ProtobufIOUtil;
 import io.protostuff.Schema;
@@ -497,11 +497,11 @@ public final class ObjectUtils {
     /**
      * 查找对象字段
      *
-     * @param clazz    对象
-     * @param function 字段回调函数
+     * @param clazz  对象
+     * @param filter 字段过滤函数
      * @return 字段实例
      */
-    public static Field findClassField(@NonNull Class<?> clazz, @NonNull Function<Field, Boolean> function) {
+    public static Field findClassField(@NonNull Class<?> clazz, @NonNull Predicate<Field> filter) {
         if (!Modifier.isInterface(clazz.getModifiers())) {
             do {
                 Field[] fields = clazz.getDeclaredFields();
@@ -511,7 +511,7 @@ public final class ObjectUtils {
                         if (!field.isSynthetic() && ((enumerable && field.isEnumConstant())
                                 || (!enumerable && !Modifier.isStatic(field.getModifiers())))) {
                             field.setAccessible(true);
-                            if (Boolean.TRUE.equals(function.apply(field))) {
+                            if (filter.test(field)) {
                                 return field;
                             }
                         }
@@ -1414,13 +1414,25 @@ public final class ObjectUtils {
     /**
      * 获取两个对象实例不同属性值
      *
-     * @param <T>      数据类型
-     * @param object   对象实例
-     * @param other    对象实例
-     * @param excludes 需要排除的属性名称集合
+     * @param <T>    数据类型
+     * @param object 对象实例
+     * @param other  对象实例
      * @return 不同属性值
      */
-    public static <T> List<Modification> compare(T object, T other, @NonNull String... excludes) {
+    public static <T> List<Modification> compare(T object, T other) {
+        return compare(object, other, field -> true);
+    }
+
+    /**
+     * 获取两个对象实例不同属性值
+     *
+     * @param <T>    数据类型
+     * @param object 对象实例
+     * @param other  对象实例
+     * @param filter 字段过滤函数
+     * @return 不同属性值
+     */
+    public static <T> List<Modification> compare(T object, T other, @NonNull Predicate<Field> filter) {
         if (object == null || other == null) {
             return Collections.emptyList();
         }
@@ -1428,34 +1440,29 @@ public final class ObjectUtils {
         if (isEmpty(fields)) {
             return Collections.emptyList();
         }
-        List<Modification> modifications = Lists.newArrayListWithCapacity(fields.size());
-        Set<String> _excludes = excludes.length == 0 ? Collections.emptySet() : Sets.newHashSet(excludes);
-        fields.forEach((name, field) -> {
-            if (_excludes.isEmpty() || !_excludes.contains(name)) {
-                Object before = getObjectValue(object, field);
-                Object after = getObjectValue(other, field);
-                if (!equals(before, after)) {
-                    modifications.add(Modification.builder().name(name).before(before).after(after).build());
-                }
-            }
-        });
-        return modifications;
+        return fields.entrySet().stream().filter(entry -> filter.test(entry.getValue())).map(entry -> {
+            String name = entry.getKey();
+            Field field = entry.getValue();
+            Object before = getObjectValue(object, field);
+            Object after = getObjectValue(other, field);
+            return equals(before, after) ? null : Modification.builder().name(name).before(before).after(after).build();
+        }).filter(Objects::nonNull).collect(Collectors.toList());
     }
 
     /**
      * 循环获取对象
      *
      * @param supplier 对象提供函数
-     * @param function 对象处理函数(返回false则中断循环)
+     * @param filter   对象过滤函数(返回false则中断循环)
      * @param <T>      对象类型
      * @return 对象实例
      */
-    public static <T> T loop(@NonNull Supplier<T> supplier, @NonNull BiFunction<Integer, T, Boolean> function) {
+    public static <T> T loop(@NonNull Supplier<T> supplier, @NonNull BiPredicate<Integer, T> filter) {
         T t;
         int count = 1;
         do {
             t = supplier.get();
-        } while (Boolean.TRUE.equals(function.apply(count++, t)));
+        } while (filter.test(count++, t));
         return t;
     }
 

+ 4 - 3
framework-common/src/main/java/com/chelvc/framework/common/util/StringUtils.java

@@ -10,6 +10,7 @@ import java.util.concurrent.ThreadLocalRandom;
 import java.util.function.BiFunction;
 import java.util.function.Consumer;
 import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.function.Supplier;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -1143,13 +1144,13 @@ public final class StringUtils {
      *
      * @param text     文本内容
      * @param regex    正则表达式
-     * @param consumer 查找结果处理函数,如果返回true则中断循环
+     * @param consumer 查找结果处理函数,返回true则中断循环
      */
-    public static void find(String text, @NonNull String regex, @NonNull Function<String, Boolean> consumer) {
+    public static void find(String text, @NonNull String regex, @NonNull Predicate<String> consumer) {
         if (notEmpty(text)) {
             Matcher matcher = getPattern(regex).matcher(text);
             while (matcher.find()) {
-                if (!Boolean.TRUE.equals(consumer.apply(matcher.group()))) {
+                if (consumer.test(matcher.group())) {
                     break;
                 }
             }

+ 5 - 6
framework-common/src/main/java/com/chelvc/framework/common/util/ThreadUtils.java

@@ -8,7 +8,7 @@ import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
-import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
@@ -182,7 +182,7 @@ public final class ThreadUtils {
      * @param <T>      消息类型
      * @return 消费线程
      */
-    public static <T> Thread consume(@NonNull Queue<T> queue, @NonNull Function<T, Boolean> consumer) {
+    public static <T> Thread consume(@NonNull Queue<T> queue, @NonNull Predicate<T> consumer) {
         return run(() -> {
             while (!Thread.currentThread().isInterrupted()) {
                 // 从队列中获取消息
@@ -194,8 +194,7 @@ public final class ThreadUtils {
 
                 // 消费消息
                 try {
-                    Boolean success = consumer.apply(message);
-                    if (Boolean.TRUE.equals(success)) {
+                    if (consumer.test(message)) {
                         // 处理成功后移除消息
                         queue.remove();
                     }
@@ -315,7 +314,7 @@ public final class ThreadUtils {
      * @param <T>      消息类型
      * @return 消息队列
      */
-    public static <T> BlockingQueue<T> queue(@NonNull Function<T, Boolean> consumer) {
+    public static <T> BlockingQueue<T> queue(@NonNull Predicate<T> consumer) {
         return queue(1000, consumer);
     }
 
@@ -351,7 +350,7 @@ public final class ThreadUtils {
      * @param <T>      消息类型
      * @return 消息队列
      */
-    public static <T> BlockingQueue<T> queue(int capacity, @NonNull Function<T, Boolean> consumer) {
+    public static <T> BlockingQueue<T> queue(int capacity, @NonNull Predicate<T> consumer) {
         BlockingQueue<T> queue = new ArrayBlockingQueue<>(Math.max(capacity, 1));
         consume(queue, consumer);
         return queue;

+ 14 - 14
framework-common/src/main/java/com/chelvc/framework/common/util/TreeUtils.java

@@ -9,7 +9,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.function.BiConsumer;
 import java.util.function.Consumer;
-import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 import com.chelvc.framework.common.model.Tree;
@@ -129,7 +129,7 @@ public final class TreeUtils {
      * @return 树节点
      */
     public static <ID extends Serializable, T extends Tree<ID, T>> T lookup(T tree, @NonNull ID id) {
-        return lookup(tree, (Function<T, Boolean>) t -> Objects.equals(t.getId(), id));
+        return lookup(tree, (Predicate<T>) t -> Objects.equals(t.getId(), id));
     }
 
     /**
@@ -142,36 +142,36 @@ public final class TreeUtils {
      * @return 树节点
      */
     public static <ID extends Serializable, T extends Tree<ID, T>> T lookup(Collection<T> trees, @NonNull ID id) {
-        return lookup(trees, (Function<T, Boolean>) t -> Objects.equals(t.getId(), id));
+        return lookup(trees, (Predicate<T>) t -> Objects.equals(t.getId(), id));
     }
 
     /**
      * 查找树节点
      *
-     * @param tree     树对象实例
-     * @param function 对象回调方法
-     * @param <T>      树节点类型
+     * @param tree   树对象实例
+     * @param filter 树过滤函数
+     * @param <T>    树节点类型
      * @return 树节点
      */
-    public static <T extends Tree<?, T>> T lookup(T tree, @NonNull Function<T, Boolean> function) {
-        return tree == null || Boolean.TRUE.equals(function.apply(tree)) ? tree : lookup(tree.getChildren(), function);
+    public static <T extends Tree<?, T>> T lookup(T tree, @NonNull Predicate<T> filter) {
+        return tree == null || filter.test(tree) ? tree : lookup(tree.getChildren(), filter);
     }
 
     /**
      * 查找树节点
      *
-     * @param trees    树对象实例集合
-     * @param function 对象回调方法
-     * @param <T>      树节点类型
+     * @param trees  树对象实例集合
+     * @param filter 树过滤函数
+     * @param <T>    树节点类型
      * @return 树节点
      */
-    public static <T extends Tree<?, T>> T lookup(Collection<T> trees, @NonNull Function<T, Boolean> function) {
+    public static <T extends Tree<?, T>> T lookup(Collection<T> trees, @NonNull Predicate<T> filter) {
         if (ObjectUtils.notEmpty(trees)) {
             for (T tree : trees) {
-                if (Boolean.TRUE.equals(function.apply(tree))) {
+                if (filter.test(tree)) {
                     return tree;
                 }
-                T t = lookup(tree.getChildren(), function);
+                T t = lookup(tree.getChildren(), filter);
                 if (Objects.nonNull(t)) {
                     return t;
                 }

+ 25 - 6
framework-database/src/main/java/com/chelvc/framework/database/support/AbstractCreateMethod.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
 import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
+import com.chelvc.framework.common.util.ObjectUtils;
 import com.chelvc.framework.common.util.StringUtils;
 import lombok.NonNull;
 import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
@@ -37,9 +39,17 @@ public abstract class AbstractCreateMethod extends AbstractMethod {
      * @return 字段信息
      */
     protected String getColumns(TableInfo table) {
-        String columns = table.getKeyInsertSqlColumn(false) +
-                this.filterTableFieldInfo(table.getFieldList(), null, TableFieldInfo::getInsertSqlColumn, EMPTY);
-        return columns.substring(0, columns.length() - 1);
+        StringBuilder buffer = new StringBuilder();
+        if (table.havePK() && table.getIdType() != IdType.AUTO) {
+            buffer.append(table.getKeyColumn());
+        }
+        for (TableFieldInfo field : table.getFieldList()) {
+            if (buffer.length() > 0) {
+                buffer.append(COMMA);
+            }
+            buffer.append(field.getColumn());
+        }
+        return buffer.toString();
     }
 
     /**
@@ -60,9 +70,18 @@ public abstract class AbstractCreateMethod extends AbstractMethod {
      * @return 属性信息
      */
     protected String getProperties(TableInfo table, String prefix) {
-        String properties = table.getKeyInsertSqlProperty(prefix, false) +
-                this.filterTableFieldInfo(table.getFieldList(), null, i -> i.getInsertSqlProperty(prefix), EMPTY);
-        return properties.substring(0, properties.length() - 1);
+        StringBuilder buffer = new StringBuilder();
+        prefix = ObjectUtils.ifNull(prefix, StringUtils.EMPTY);
+        if (table.havePK() && table.getIdType() != IdType.AUTO) {
+            buffer.append(SqlScriptUtils.safeParam(prefix + table.getKeyProperty()));
+        }
+        for (TableFieldInfo field : table.getFieldList()) {
+            if (buffer.length() > 0) {
+                buffer.append(COMMA);
+            }
+            buffer.append(SqlScriptUtils.safeParam(prefix + field.getEl()));
+        }
+        return buffer.toString();
     }
 
     /**

+ 14 - 49
framework-database/src/main/java/com/chelvc/framework/database/support/Updates.java

@@ -4,7 +4,7 @@ import java.io.Serializable;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Set;
+import java.util.function.Predicate;
 
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
 import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
@@ -15,7 +15,6 @@ import com.chelvc.framework.common.util.ObjectUtils;
 import com.chelvc.framework.common.util.StringUtils;
 import com.chelvc.framework.database.context.DatabaseContextHolder;
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 import lombok.NonNull;
 
 /**
@@ -71,7 +70,7 @@ public final class Updates {
      * @return 字段更新对象实例
      */
     public static <T> Update<T> all(@NonNull Class<T> clazz) {
-        return all(clazz, null);
+        return all(clazz, null, property -> true);
     }
 
     /**
@@ -83,31 +82,32 @@ public final class Updates {
      * @return 字段更新对象实例
      */
     public static <T> Update<T> all(@NonNull Class<T> clazz, Condition condition) {
-        return not(clazz, condition, StringUtils.EMPTY_ARRAY);
+        return all(clazz, condition, property -> true);
     }
 
+
     /**
-     * 更新除指定字段外的所有字段
+     * 更新所有字段
      *
-     * @param clazz   对象类型
-     * @param columns 排除字段数组
-     * @param <T>     数据类型
+     * @param clazz  对象类型
+     * @param filter 过滤函数
+     * @param <T>    数据类型
      * @return 字段更新对象实例
      */
-    public static <T> Update<T> not(@NonNull Class<T> clazz, @NonNull String... columns) {
-        return not(clazz, null, columns);
+    public static <T> Update<T> all(@NonNull Class<T> clazz, @NonNull Predicate<String> filter) {
+        return all(clazz, null, filter);
     }
 
     /**
-     * 更新除指定字段外的所有字段
+     * 更新所有字段
      *
      * @param clazz     对象类型
      * @param condition 更新条件
-     * @param columns   排除字段数组
+     * @param filter    过滤函数
      * @param <T>       数据类型
      * @return 字段更新对象实例
      */
-    public static <T> Update<T> not(@NonNull Class<T> clazz, Condition condition, @NonNull String... columns) {
+    public static <T> Update<T> all(@NonNull Class<T> clazz, Condition condition, @NonNull Predicate<String> filter) {
         Update<T> update = update();
         Map<String, ColumnCache> properties = LambdaUtils.getColumnMap(clazz);
         if (ObjectUtils.isEmpty(properties)) {
@@ -115,49 +115,14 @@ public final class Updates {
         }
         TableInfo table = TableInfoHelper.getTableInfo(clazz);
         String key = StringUtils.ifEmpty(table.getKeyProperty(), LambdaUtils::formatKey);
-        Set<String> excludes = ObjectUtils.isEmpty(columns) ? Collections.emptySet() : Sets.newHashSet(columns);
         properties.forEach((property, column) -> {
-            if (!Objects.equals(property, key) && !excludes.contains(column.getColumn())) {
+            if (!Objects.equals(property, key) && filter.test(property)) {
                 update.use(condition, column.getColumn());
             }
         });
         return update;
     }
 
-    /**
-     * 更新除指定字段外的所有字段
-     *
-     * @param clazz   对象类型
-     * @param getters 排除Getter方法数组
-     * @param <T>     数据类型
-     * @return 字段更新对象实例
-     */
-    @SafeVarargs
-    public static <T> Update<T> not(@NonNull Class<T> clazz, @NonNull SFunction<T, ?>... getters) {
-        return not(clazz, null, getters);
-    }
-
-    /**
-     * 更新除指定字段外的所有字段
-     *
-     * @param clazz     对象类型
-     * @param condition 更新条件
-     * @param getters   排除Getter方法数组
-     * @param <T>       数据类型
-     * @return 字段更新对象实例
-     */
-    @SafeVarargs
-    public static <T> Update<T> not(@NonNull Class<T> clazz, Condition condition, @NonNull SFunction<T, ?>... getters) {
-        if (ObjectUtils.isEmpty(getters)) {
-            return not(clazz, StringUtils.EMPTY_ARRAY);
-        }
-        String[] columns = new String[getters.length];
-        for (int i = 0; i < getters.length; i++) {
-            columns[i] = DatabaseContextHolder.getter2column(getters[i]);
-        }
-        return not(clazz, condition, columns);
-    }
-
     /**
      * 使用
      *

+ 8 - 11
framework-rocketmq/src/main/java/com/chelvc/framework/rocketmq/context/RocketMQContextHolder.java

@@ -8,6 +8,7 @@ import java.util.List;
 import java.util.Objects;
 import java.util.function.BiFunction;
 import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 import com.chelvc.framework.base.context.ApplicationContextHolder;
@@ -330,12 +331,11 @@ public final class RocketMQContextHolder {
      *
      * @param topic    消息主题
      * @param payload  消息内容
-     * @param executor 本地事务执行方法
+     * @param callback 本地事务回调函数
      * @param <T>      消息类型
      */
-    public static <T> void send(@NonNull String topic, @NonNull T payload,
-                                @NonNull Function<MessageId, Boolean> executor) {
-        send(topic, payload, null, executor);
+    public static <T> void send(@NonNull String topic, @NonNull T payload, @NonNull Predicate<MessageId> callback) {
+        send(topic, payload, null, callback);
     }
 
     /**
@@ -344,11 +344,11 @@ public final class RocketMQContextHolder {
      * @param topic    消息主题
      * @param payload  消息内容
      * @param ordering 顺序消息标识
-     * @param executor 本地事务执行方法
+     * @param callback 本地事务回调函数
      * @param <T>      消息类型
      */
     public static <T> void send(@NonNull String topic, @NonNull T payload, String ordering,
-                                @NonNull Function<MessageId, Boolean> executor) {
+                                @NonNull Predicate<MessageId> callback) {
         // 发送事务半消息
         MessageId id;
         Transaction transaction;
@@ -361,12 +361,9 @@ public final class RocketMQContextHolder {
             throw new RuntimeException(e);
         }
 
-        // 执行本地事务回调函数
-        Boolean success = executor.apply(id);
-
-        // 提交/回滚消息事务
+        // 处理本地事务
         try {
-            if (Boolean.TRUE.equals(success)) {
+            if (callback.test(id)) {
                 transaction.commit();
             } else {
                 transaction.rollback();

+ 5 - 5
framework-sms/src/main/java/com/chelvc/framework/sms/CaptchaSmsHandler.java

@@ -1,6 +1,6 @@
 package com.chelvc.framework.sms;
 
-import java.util.function.Function;
+import java.util.function.Predicate;
 
 /**
  * 短信验证码操作接口
@@ -38,14 +38,14 @@ public interface CaptchaSmsHandler {
      * 使用验证码(使用后移除)
      *
      * @param mobile   手机号
-     * @param function 验证码应用回调接口(返回true则移除验证码)
+     * @param callback 验证码应用回调接口(返回true则移除验证码)
      */
-    void using(String mobile, Function<Captcha, Boolean> function);
+    void using(String mobile, Predicate<Captcha> callback);
 
     /**
      * 检测验证码是否正确
      *
-     * @param id     短信标识
+     * @param id     令牌标识
      * @param mobile 手机号
      * @param code   验证码
      * @return true/false
@@ -55,7 +55,7 @@ public interface CaptchaSmsHandler {
     /**
      * 校验验证码是否正确(校验成功后移除)
      *
-     * @param id     短信标识
+     * @param id     令牌标识
      * @param mobile 手机号
      * @param code   验证码
      * @return true/false

+ 3 - 3
framework-sms/src/main/java/com/chelvc/framework/sms/support/DefaultCaptchaSmsHandler.java

@@ -5,7 +5,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
+import java.util.function.Predicate;
 
 import com.chelvc.framework.base.context.ApplicationContextHolder;
 import com.chelvc.framework.common.util.AssertUtils;
@@ -110,9 +110,9 @@ public class DefaultCaptchaSmsHandler implements CaptchaSmsHandler {
     }
 
     @Override
-    public void using(@NonNull String mobile, @NonNull Function<Captcha, Boolean> function) {
+    public void using(@NonNull String mobile, @NonNull Predicate<Captcha> callback) {
         Captcha captcha = this.getCaptcha(mobile);
-        if (Boolean.TRUE.equals(function.apply(captcha))) {
+        if (callback.test(captcha)) {
             RedisContextHolder.getDefaultTemplate().delete(this.key(mobile));
         }
     }

+ 3 - 3
framework-sms/src/main/java/com/chelvc/framework/sms/support/DelegatingNormalSmsHandler.java

@@ -1,7 +1,7 @@
 package com.chelvc.framework.sms.support;
 
 import java.util.List;
-import java.util.function.Function;
+import java.util.function.Predicate;
 
 import com.chelvc.framework.common.util.AssertUtils;
 import com.chelvc.framework.sms.NormalSmsHandler;
@@ -30,11 +30,11 @@ public class DelegatingNormalSmsHandler implements NormalSmsHandler {
      * @param callback 短信处理回调函数
      * @return true/false
      */
-    private boolean execute(Function<NormalSmsHandler, Boolean> callback) {
+    private boolean execute(Predicate<NormalSmsHandler> callback) {
         Exception unsupported = null;
         for (NormalSmsHandler handler : this.handlers) {
             try {
-                if (Boolean.TRUE.equals(callback.apply(handler))) {
+                if (callback.test(handler)) {
                     return true;
                 }
             } catch (Exception e) {