public MiniCart( final Cart cart, final UserContext userContext, final ReverseRouter reverseRouter) { final MoneyContext moneyContext = MoneyContext.of(cart.getCurrency(), userContext.locale()); this.totalItems = cart.getLineItems().stream().mapToLong(LineItem::getQuantity).sum(); this.totalPrice = moneyContext.formatOrZero(calculateTotalPrice(cart)); this.lineItems = new MiniCartLineItemsBean(cart, userContext, reverseRouter); }
public BannerData(final UserContext userContext, final Category category) { setTitle(category.getName().find(userContext.locales()).orElse("")); Optional.ofNullable(category.getDescription()) .ifPresent( description -> setDescription(description.find(userContext.locales()).orElse(""))); }