setValueIfBlank方法支持泛型

This commit is contained in:
smallchill 2024-05-18 12:46:45 +08:00
parent 0fc9e1fa79
commit 22e3e046d4

View File

@ -47,8 +47,8 @@ public class ValidationUtil {
* @param setter 字段的setter方法 * @param setter 字段的setter方法
* @param valueSupplier 默认值提供方法 * @param valueSupplier 默认值提供方法
*/ */
public static void setValueIfBlank(Supplier<String> getter, Consumer<String> setter, Supplier<String> valueSupplier) { public static <T> void setValueIfBlank(Supplier<T> getter, Consumer<T> setter, Supplier<T> valueSupplier) {
if (StringUtil.isBlank(getter.get())) { if (ObjectUtil.isEmpty(getter.get())) {
setter.accept(valueSupplier.get()); setter.accept(valueSupplier.get());
} }
} }