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

io.sphere.sdk.states.StateDraftBuilder Maven / Gradle / Ivy

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

import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.models.LocalizedString;
import io.sphere.sdk.models.Reference;

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

public final class StateDraftBuilder extends Base implements Builder {
    private final String key;
    private StateType type;
    @Nullable
    private LocalizedString name;
    @Nullable
    private LocalizedString description;
    @Nullable
    private Boolean initial;
    @Nullable
    private Set> transitions;

    private StateDraftBuilder(final String key, final StateType type) {
        this.key = key;
        this.type = type;
    }

    public static StateDraftBuilder of(final String key, final StateType type) {
        return new StateDraftBuilder(key, type);
    }

    public static StateDraftBuilder of(final StateDraft template) {
        return new StateDraftBuilder(template.getKey(), template.getType())
                .name(template.getName())
                .description(template.getDescription())
                .transitions(template.getTransitions())
                .initial(template.isInitial());
    }

    public StateDraftBuilder name(@Nullable final LocalizedString name) {
        this.name = name;
        return this;
    }

    public StateDraftBuilder description(@Nullable final LocalizedString description) {
        this.description = description;
        return this;
    }

    public StateDraftBuilder initial(@Nullable final Boolean initial) {
        this.initial = initial;
        return this;
    }

    public StateDraftBuilder transitions(@Nullable final Set> transitions) {
        this.transitions = transitions;
        return this;
    }

    public StateDraftBuilder type(final StateType type) {
        this.type = type;
        return this;
    }

    @Override
    public StateDraft build() {
        return new StateDraft(key, type, name, description, initial, transitions);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy