io.sphere.sdk.states.StateDraft Maven / Gradle / Ivy
package io.sphere.sdk.states;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.LocalizedStrings;
import io.sphere.sdk.models.Reference;
import java.util.Optional;
import java.util.Set;
/**
* Template to create a new State.
*
* @see StateDraftBuilder
*/
public class StateDraft extends Base {
private final String key;
private final StateType type;
private final Optional name;
private final Optional description;
private final Optional initial;
private final Optional>> transitions;
StateDraft(String key, StateType type, Optional name, Optional description,
Optional initial, Optional>> transitions) {
this.key = key;
this.type = type;
this.name = name;
this.description = description;
this.initial = initial;
this.transitions = transitions;
}
public static StateDraft of(final String key, final StateType type) {
return new StateDraft(key, type, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
}
public String getKey() {
return key;
}
public StateType getType() {
return type;
}
public Optional getName() {
return name;
}
public Optional getDescription() {
return description;
}
public Optional isInitial() {
return initial;
}
public Optional>> getTransitions() {
return transitions;
}
public StateDraft withName(final LocalizedStrings name) {
return StateDraftBuilder.of(this).name(name).build();
}
public StateDraft withDescription(final LocalizedStrings description) {
return StateDraftBuilder.of(this).description(description).build();
}
public StateDraft withTransitions(final Optional>> transitions) {
return StateDraftBuilder.of(this).transitions(transitions).build();
}
public StateDraft withTransitions(final Set> transitions) {
return withTransitions(Optional.of(transitions));
}
public StateDraft withInitial(final boolean initial) {
return StateDraftBuilder.of(this).initial(initial).build();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy