我想将流转换为BigDecimal
对象。我的代码:
@Named
@Dependent
public class NoteSumOrderValidator implements RosterIntegrityConstraintValidator {
@Inject
private MessageBundle bundle;
@Override
public List<Notification> validate(Roster roster) {
Map<String, Map<String, Map<String, Map<String, Map<String, List<RosterRow>>>>>> rost = roster.getRows().stream()
.collect(Collectors.groupingBy(RosterRow::getBeneficiarySurname,
Collectors.groupingBy(RosterRow::getBeneficiaryName,
Collectors.groupingBy(RosterRow::getBeneficiaryPatronymic,
Collectors.groupingBy(RosterRow::getBeneficiaryIdentificationDocumentSerial,
Collectors.groupingBy(RosterRow::getBeneficiaryIdentificationDocumentNumber)
)))));
final BigDecimal MAX_ALLOWED = BigDecimal.valueOf(499_999.99);
rost.entrySet().stream()
.map(entry -> rost.get(entry.getKey()))
.map(each -> each.entrySet())
.flatMap(Collection::stream)
.map(entry -> entry.getValue())
.map(each -> each.entrySet())
.flatMap(Collection::stream)
.map(entry -> entry.getValue())
.map(each -> each.entrySet())
.flatMap(Collection::stream)
.map(entry -> entry.getValue())
.map(each -> each.entrySet())
.flatMap(Collection::stream)
.map(entry -> entry.getValue())
.forEach(group -> {
BigDecimal totalAmount = group.stream()
.filter(row -> row.getComment().contains("сумма"))
.map(RosterRow::getAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// List<String> objList = new ArrayList();;
// BigDeciaml bd = group.stream().filter(row -> row.getComment())
BigDecimal totalAmount1 = group.stream()
.filter(row -> row.getComment().contains("сумма"))
.map(BigDecimal::new);
BigDecimal totalAmount1 = group.stream()
.filter(row -> row.getComment().contains("сумма"))
.map(BigDecimal::new);
它说这是不相容的。