Class StateDraftBuilder

java.lang.Object
com.commercetools.api.models.state.StateDraftBuilder
All Implemented Interfaces:
Builder<StateDraft>

public class StateDraftBuilder extends Object implements Builder<StateDraft>
StateDraftBuilder
Example to create an instance using the builder pattern

     StateDraft stateDraft = StateDraft.builder()
             .key("{key}")
             .type(StateTypeEnum.ORDER_STATE)
             .build()
 
  • Constructor Details

    • StateDraftBuilder

      public StateDraftBuilder()
  • Method Details

    • key

      public StateDraftBuilder key(String key)

      User-defined unique identifier for the State.

      Parameters:
      key - value to be set
      Returns:
      Builder
    • type

      public StateDraftBuilder type(StateTypeEnum type)

      Specify to which resource or object type the State is assigned to.

      Parameters:
      type - value to be set
      Returns:
      Builder
    • name

      Name of the State.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • withName

      Name of the State.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • name

      Name of the State.

      Parameters:
      name - value to be set
      Returns:
      Builder
    • description

      Description of the State.

      Parameters:
      builder - function to build the description value
      Returns:
      Builder
    • withDescription

      Description of the State.

      Parameters:
      builder - function to build the description value
      Returns:
      Builder
    • description

      public StateDraftBuilder description(@Nullable LocalizedString description)

      Description of the State.

      Parameters:
      description - value to be set
      Returns:
      Builder
    • initial

      public StateDraftBuilder initial(@Nullable Boolean initial)

      Set to false if the State is not the first step in a workflow.

      Parameters:
      initial - value to be set
      Returns:
      Builder
    • roles

      public StateDraftBuilder roles(@Nullable StateRoleEnum... roles)

      If suitable, assign predifined roles the State can fulfill in case the State's type is LineItemState or ReviewState.

      Parameters:
      roles - value to be set
      Returns:
      Builder
    • roles

      If suitable, assign predifined roles the State can fulfill in case the State's type is LineItemState or ReviewState.

      Parameters:
      roles - value to be set
      Returns:
      Builder
    • plusRoles

      public StateDraftBuilder plusRoles(@Nullable StateRoleEnum... roles)

      If suitable, assign predifined roles the State can fulfill in case the State's type is LineItemState or ReviewState.

      Parameters:
      roles - value to be set
      Returns:
      Builder
    • transitions

      public StateDraftBuilder transitions(@Nullable StateResourceIdentifier... transitions)

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Parameters:
      transitions - value to be set
      Returns:
      Builder
    • transitions

      public StateDraftBuilder transitions(@Nullable List<StateResourceIdentifier> transitions)

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Parameters:
      transitions - value to be set
      Returns:
      Builder
    • plusTransitions

      public StateDraftBuilder plusTransitions(@Nullable StateResourceIdentifier... transitions)

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Parameters:
      transitions - value to be set
      Returns:
      Builder
    • plusTransitions

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • withTransitions

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • addTransitions

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • setTransitions

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • getKey

      public String getKey()

      User-defined unique identifier for the State.

      Returns:
      key
    • getType

      public StateTypeEnum getType()

      Specify to which resource or object type the State is assigned to.

      Returns:
      type
    • getName

      @Nullable public LocalizedString getName()

      Name of the State.

      Returns:
      name
    • getDescription

      @Nullable public LocalizedString getDescription()

      Description of the State.

      Returns:
      description
    • getInitial

      @Nullable public Boolean getInitial()

      Set to false if the State is not the first step in a workflow.

      Returns:
      initial
    • getRoles

      @Nullable public List<StateRoleEnum> getRoles()

      If suitable, assign predifined roles the State can fulfill in case the State's type is LineItemState or ReviewState.

      Returns:
      roles
    • getTransitions

      @Nullable public List<StateResourceIdentifier> getTransitions()

      Define the list of States of the same type to which the current State can be transitioned to.

      • If, for example, the current State is the Initial State of StateType OrderState and you want to allow the transition Initial -> Shipped, then add the StateResourceIdentifier to the Shipped OrderState to this list.
      • Set to empty list for not allowing any transition from the current State and defining it as final State for a workflow.
      • Do not set this field at all to turn off validation and allowing transitions to any other State of the same type as the current State.
      Returns:
      transitions
    • build

      public StateDraft build()
      builds StateDraft with checking for non-null required values
      Specified by:
      build in interface Builder<StateDraft>
      Returns:
      StateDraft
    • buildUnchecked

      public StateDraft buildUnchecked()
      builds StateDraft without checking for non-null required values
      Returns:
      StateDraft
    • of

      public static StateDraftBuilder of()
      factory method for an instance of StateDraftBuilder
      Returns:
      builder
    • of

      public static StateDraftBuilder of(StateDraft template)
      create builder for StateDraft instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder