All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.commercetools.sunrise.shoppingcart.CartBeanFactory Maven / Gradle / Ivy

There is a newer version: 1.0.0-M10
Show newest version
package com.commercetools.sunrise.shoppingcart;

import io.sphere.sdk.carts.Cart;
import io.sphere.sdk.carts.LineItem;

import javax.annotation.Nullable;
import javax.inject.Inject;

public class CartBeanFactory extends CartLikeBeanFactory {

    @Inject
    private LineItemExtendedBeanFactory lineItemExtendedBeanFactory;

    public CartBean create(@Nullable final Cart cart) {
        final CartBean bean = new CartBean();
        initialize(bean, cart);
        return bean;
    }

    protected final void initialize(final CartBean bean, @Nullable final Cart cart) {
        if (cart != null) {
            fillCartInfo(bean, cart);
        } else {
            fillEmptyCartInfo(bean);
        }
    }

    @Override
    protected LineItemBean createLineItem(final LineItem lineItem) {
        return lineItemExtendedBeanFactory.create(lineItem);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy