mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method
This commit is contained in:
@@ -448,6 +448,17 @@ public class Opt<T> {
|
||||
return isPresent() ? value : supplier.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果包裹里元素的值存在,则返回该值,否则返回传入的操作执行后的返回值
|
||||
*
|
||||
* @param supplier 值不存在时需要执行的操作,返回一个类型与 包裹里元素类型 相同的元素
|
||||
* @return 如果包裹里元素的值存在,则返回该值,否则返回传入的操作执行后的返回值
|
||||
* @throws NullPointerException 如果之不存在,并且传入的操作为空,则抛出 {@code NPE}
|
||||
*/
|
||||
public Opt<T> orElseOpt(final Supplier<? extends T> supplier) {
|
||||
return or(() -> Opt.ofNullable(supplier.get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果包裹里元素的值存在,则返回该值,否则执行传入的操作
|
||||
*
|
||||
|
@@ -86,6 +86,16 @@ public class LogEngineFactory {
|
||||
logEngine.createLog(LogEngineFactory.class).debug("Custom Use [{}] Logger.", logEngine.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建指定日志实现引擎
|
||||
*
|
||||
* @param logEngineClass 引擎类
|
||||
* @return {@link LogEngine}
|
||||
*/
|
||||
public static LogEngine createEngine(final Class<? extends LogEngine> logEngineClass) {
|
||||
return ConstructorUtil.newInstance(logEngineClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 决定日志实现
|
||||
* <p>
|
||||
|
Reference in New Issue
Block a user