mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-11-15 06:59:29 +08:00
⚡ setValueIfBlank方法支持泛型
This commit is contained in:
parent
0fc9e1fa79
commit
22e3e046d4
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user