Class StateBuilder

java.lang.Object
com.commercetools.api.models.state.StateBuilder
All Implemented Interfaces:
io.vrap.rmf.base.client.Builder<State>

public class StateBuilder extends Object implements io.vrap.rmf.base.client.Builder<State>
StateBuilder
Example to create an instance using the builder pattern

     State state = State.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .key("{key}")
             .type(StateTypeEnum.ORDER_STATE)
             .initial(true)
             .builtIn(true)
             .build()
 
  • Constructor Details

    • StateBuilder

      public StateBuilder()
  • Method Details

    • id

      public StateBuilder id(String id)

      Unique identifier of the State.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • version

      public StateBuilder version(Long version)

      Current version of the State.

      Parameters:
      version - value to be set
      Returns:
      Builder
    • createdAt

      public StateBuilder createdAt(ZonedDateTime createdAt)

      Date and time (UTC) the State was initially created.

      Parameters:
      createdAt - value to be set
      Returns:
      Builder
    • lastModifiedAt

      public StateBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

      Date and time (UTC) the State was last updated.

      Parameters:
      lastModifiedAt - value to be set
      Returns:
      Builder
    • lastModifiedBy

      Present on resources created after 1 February 2019 except for events not tracked.

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

      public StateBuilder withLastModifiedBy(Function<LastModifiedByBuilder,LastModifiedBy> builder)

      Present on resources created after 1 February 2019 except for events not tracked.

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

      public StateBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      Present on resources created after 1 February 2019 except for events not tracked.

      Parameters:
      lastModifiedBy - value to be set
      Returns:
      Builder
    • createdBy

      Present on resources created after 1 February 2019 except for events not tracked.

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

      public StateBuilder withCreatedBy(Function<CreatedByBuilder,CreatedBy> builder)

      Present on resources created after 1 February 2019 except for events not tracked.

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

      public StateBuilder createdBy(@Nullable CreatedBy createdBy)

      Present on resources created after 1 February 2019 except for events not tracked.

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

      public StateBuilder key(String key)

      User-defined unique identifier of the State.

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

      public StateBuilder type(StateTypeEnum type)

      Indicates to which resource or object types 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

      public StateBuilder withDescription(Function<LocalizedStringBuilder,LocalizedString> builder)

      Description of the State.

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

      public StateBuilder description(@Nullable LocalizedString description)

      Description of the State.

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

      public StateBuilder initial(Boolean initial)

      true for an initial State, the first State in a workflow.

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

      public StateBuilder builtIn(Boolean builtIn)

      true for States that are an integral part of the Project. Those States cannot be deleted and their key cannot be changed.

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

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

      Roles the State can fulfill for Reviews and Line Items.

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

      public StateBuilder roles(@Nullable List<StateRoleEnum> roles)

      Roles the State can fulfill for Reviews and Line Items.

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

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

      Roles the State can fulfill for Reviews and Line Items.

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

      public StateBuilder transitions(@Nullable StateReference... transitions)
      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Parameters:
      transitions - value to be set
      Returns:
      Builder
    • transitions

      public StateBuilder transitions(@Nullable List<StateReference> transitions)
      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Parameters:
      transitions - value to be set
      Returns:
      Builder
    • plusTransitions

      public StateBuilder plusTransitions(@Nullable StateReference... transitions)
      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Parameters:
      transitions - value to be set
      Returns:
      Builder
    • plusTransitions

      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • withTransitions

      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • addTransitions

      public StateBuilder addTransitions(Function<StateReferenceBuilder,StateReference> builder)
      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • setTransitions

      public StateBuilder setTransitions(Function<StateReferenceBuilder,StateReference> builder)
      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Parameters:
      builder - function to build the transitions value
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the State.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the State.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

      Date and time (UTC) the State was initially created.

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

      Date and time (UTC) the State was last updated.

      Returns:
      lastModifiedAt
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      Present on resources created after 1 February 2019 except for events not tracked.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      Present on resources created after 1 February 2019 except for events not tracked.

      Returns:
      createdBy
    • getKey

      public String getKey()

      User-defined unique identifier of the State.

      Returns:
      key
    • getType

      public StateTypeEnum getType()

      Indicates to which resource or object types 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

      public Boolean getInitial()

      true for an initial State, the first State in a workflow.

      Returns:
      initial
    • getBuiltIn

      public Boolean getBuiltIn()

      true for States that are an integral part of the Project. Those States cannot be deleted and their key cannot be changed.

      Returns:
      builtIn
    • getRoles

      @Nullable public List<StateRoleEnum> getRoles()

      Roles the State can fulfill for Reviews and Line Items.

      Returns:
      roles
    • getTransitions

      @Nullable public List<StateReference> getTransitions()
      • list of States of the same type that the current State can be transitioned to. For example, when the current State is the Initial State of StateType OrderState and this list contains the reference to the Shipped OrderState, the transition Initial -> Shipped is allowed.
      • if empty, no transitions are allowed from the current State, defining the current State as final for this workflow.
      • if not set, the validation is turned off and the current State can be transitioned to any other State of the same type as the current State.
      Returns:
      transitions
    • build

      public State build()
      builds State with checking for non-null required values
      Specified by:
      build in interface io.vrap.rmf.base.client.Builder<State>
      Returns:
      State
    • buildUnchecked

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

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

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