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

io.sphere.sdk.states.relatedupdateactions.TransitionStateBase Maven / Gradle / Ivy

There is a newer version: 2.16.0
Show newest version
package io.sphere.sdk.states.relatedupdateactions;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.models.ResourceIdentifiable;
import io.sphere.sdk.models.ResourceIdentifier;
import io.sphere.sdk.states.State;

import javax.annotation.Nullable;
import java.util.Optional;

/**
 * Internal base class
 * @param  type to be updated
 */
public abstract class TransitionStateBase extends UpdateActionImpl {
    @Nullable
    private final ResourceIdentifier state;
    @Nullable
    private final Boolean force;

    protected TransitionStateBase(final @Nullable ResourceIdentifiable state, final Boolean force) {
        super("transitionState");
        this.force = force;
        this.state = Optional.ofNullable(state).map(ResourceIdentifiable::toResourceIdentifier).orElse(null);
    }

    protected TransitionStateBase(final @Nullable ResourceIdentifiable state) {
        this(state, null);
    }

    @Nullable
    public ResourceIdentifier getState() {
        return state;
    }

    /**
     * Using true disables the state machine validation and allows a transition in any state.
     *
     * {@include.example io.sphere.sdk.products.commands.ProductUpdateCommandIntegrationTest#transitionStateAndForce()}
     *
     * @return true if validation is turned of
     */
    @JsonProperty("force")
    @Nullable
    public Boolean isForce() {
        return force;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy