按照超哥教的 使用number替换decimal

This commit is contained in:
LoveHuahua 2023-02-19 15:14:06 +08:00
parent c6d6333cbc
commit 3092201634

View File

@ -306,13 +306,13 @@ public class EasyStream<T> extends AbstractEnhancedWrappedStream<T, EasyStream<T
} }
/** /**
* 计算decimal的总和 * 计算number的总和
* *
* @param mapper 映射 * @param mapper 映射
* @return {@link BigDecimal} * @return {@link BigDecimal}
*/ */
public BigDecimal sum(final Function<? super T, BigDecimal> mapper) { public <R extends Number> BigDecimal sum(final Function<? super T, R> mapper) {
return stream.map(mapper).reduce(BigDecimal.ZERO, BigDecimal::add); return stream.map(mapper).reduce(BigDecimal.ZERO, NumberUtil::add,NumberUtil::add);
} }