mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
Merge branch 'cj20220512' into leng_dev
This commit is contained in:
commit
73c6fa415d
1 file changed
+10
-3
+10
-3
@@ -32,13 +32,20 @@ import java.util.function.Predicate;
|
||||
/**
|
||||
* 简化{@code R<T>} 的访问操作,例子 <pre>
|
||||
* R<Integer> result = R.ok(0);
|
||||
* // 链式操作: 断言然后消费
|
||||
* // 使用场景1: 链式操作: 断言然后消费
|
||||
* RetOps.of(result)
|
||||
* .assertCode(-1,r -> new RuntimeException("error "+r.getCode()))
|
||||
* .assertDataNotEmpty(r -> new IllegalStateException("oops!"))
|
||||
* .useData(System.out::println);
|
||||
* // 访问原始值
|
||||
*
|
||||
* // 使用场景2: 读取原始值(data),这里返回的是Optional
|
||||
* RetOps.of(result).getData().orElse(null);
|
||||
*
|
||||
* // 使用场景3: 类型转换
|
||||
* R<String> s = RetOps.of(result)
|
||||
* .assertDataNotNull(r -> new IllegalStateException("nani??"))
|
||||
* .map(i -> Integer.toHexString(i))
|
||||
* .peek();
|
||||
* </pre>
|
||||
*
|
||||
* @author CJ (power4j@outlook.com)
|
||||
@@ -201,7 +208,7 @@ public class RetOps<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言业务数据有值,并且包含元素
|
||||
* 对业务数据(data)转换
|
||||
* @param mapper 业务数据转换函数
|
||||
* @param <U> 数据类型
|
||||
* @return 返回新实例,以便于继续进行链式操作
|
||||
|
||||
Reference in new issue
Block a user