update 优化代码
Signed-off-by: 秋辞未寒 <545073804@qq.com>
This commit is contained in:
parent
bab860e1a0
commit
bd9e581e01
@ -13,7 +13,7 @@ public interface BaseCycleAvoidingMapper<S, T> extends BaseMapper<S, T> {
|
||||
T convert(S source, @Context CycleAvoidingMappingContext context);
|
||||
|
||||
default T convert(S source, @Context CycleAvoidingMappingContext context, Consumer<T> beanConsumer) {
|
||||
T bean = convert(source,context);
|
||||
T bean = convert(source, context);
|
||||
if (Objects.nonNull(bean) && Objects.nonNull(beanConsumer)) {
|
||||
beanConsumer.accept(bean);
|
||||
}
|
||||
@ -23,7 +23,7 @@ public interface BaseCycleAvoidingMapper<S, T> extends BaseMapper<S, T> {
|
||||
T convert(S source, @MappingTarget T target, @Context CycleAvoidingMappingContext context);
|
||||
|
||||
default T convert(S source, @MappingTarget T target, @Context CycleAvoidingMappingContext context, Consumer<T> beanConsumer) {
|
||||
T bean = convert(source,target,context);
|
||||
T bean = convert(source, target, context);
|
||||
if (Objects.nonNull(bean) && Objects.nonNull(beanConsumer)) {
|
||||
beanConsumer.accept(bean);
|
||||
}
|
||||
@ -40,7 +40,7 @@ public interface BaseCycleAvoidingMapper<S, T> extends BaseMapper<S, T> {
|
||||
// 如果 beanConsumer 本来就为 null,则不再调用带 Consumer 参数的 convert 方法,避免在循环中进行不必要的非空判断
|
||||
if (Objects.nonNull(beanConsumer)) {
|
||||
return sourceList.stream()
|
||||
.map(source -> convert(source, beanConsumer))
|
||||
.map(source -> convert(source, context, beanConsumer))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return sourceList.stream()
|
||||
|
@ -24,7 +24,7 @@ public interface BaseMapper<S, T> {
|
||||
T convert(S source, @MappingTarget T target);
|
||||
|
||||
default T convert(S source, @MappingTarget T target, Consumer<T> beanConsumer) {
|
||||
T bean = convert(source,target);
|
||||
T bean = convert(source, target);
|
||||
if (Objects.nonNull(bean) && Objects.nonNull(beanConsumer)) {
|
||||
beanConsumer.accept(bean);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user