I'm trying to create a binding of a list of LineItem
's amounts with the following line:
ReadOnlyObjectWrapper<BigDecimal> total = new ReadOnlyObjectWrapper<>();
total.bind(Bindings.createObjectBinding(() -> items.stream()
.collect(Collectors.summingDouble(LineItem::getTotal)),
items));
Obviously, the Collectors.summingDouble
won't work as it's a BigDecimal
. Is there any way to do this with a BigDecimal?
LineItem.java
public class LineItem
{
private final SimpleObjectProperty<BigDecimal> amount;
public LineItem()
{
this.amount = new SimpleObjectProperty<>();
}
public BigDecimal getTotal()
{
return this.amount.get();
}
}
Ideally, changes to the properties will reflect in the total property...