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

io.sphere.sdk.orders.commands.updateactions.TransitionCustomLineItemState Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.orders.commands.updateactions;

import io.sphere.sdk.carts.CustomLineItem;
import io.sphere.sdk.commands.UpdateAction;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.orders.Order;
import io.sphere.sdk.states.State;

import java.time.ZonedDateTime;

/**
 * Change the state of a Custom Line Item according to allowed transitions.
 *
 * {@doc.gen intro}
 *
 * {@include.example io.sphere.sdk.orders.commands.OrderUpdateCommandTest#transitionCustomLineItemState()}
 */
public class TransitionCustomLineItemState extends TransitionLineItemLikeState {

    private final String customLineItemId;

    private TransitionCustomLineItemState(final String customLineItemId, final Long quantity, final Referenceable fromState, final Referenceable toState,
                                          final ZonedDateTime actualTransitionDate) {
        super("transitionCustomLineItemState", quantity, actualTransitionDate, toState.toReference(), fromState.toReference());
        this.customLineItemId = customLineItemId;
    }

    public String getCustomLineItemId() {
        return customLineItemId;
    }

    public static TransitionCustomLineItemState of(final String customLineItemId, final long quantity,
                                             final Referenceable fromState, final Referenceable toState,
                                             final ZonedDateTime actualTransitionDate) {
        return new TransitionCustomLineItemState(customLineItemId, quantity, fromState, toState, actualTransitionDate);
    }

    public static UpdateAction of(final CustomLineItem lineItem, final long quantity,
                                         final Referenceable fromState, final Referenceable toState,
                                         final ZonedDateTime actualTransitionDate) {
        return of(lineItem.getId(), quantity, fromState, toState, actualTransitionDate);
    }

    public static UpdateAction of(final CustomLineItem lineItem, final long quantity,
                                         final Referenceable fromState, final Referenceable toState) {
        return of(lineItem.getId(), quantity, fromState, toState, null);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy