Class ReservationBuilder

java.lang.Object
com.commercetools.api.models.reservation.ReservationBuilder
All Implemented Interfaces:
Builder<Reservation>

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

     Reservation reservation = Reservation.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .expiresAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .inventoryEntry(inventoryEntryBuilder -> inventoryEntryBuilder)
             .quantity(0.3)
             .owner(ownerBuilder -> ownerBuilder)
             .lineItemId("{lineItemId}")
             .state(ReservationState.CREATED)
             .build()
 
  • Constructor Details

    • ReservationBuilder

      public ReservationBuilder()
  • Method Details

    • id

      public ReservationBuilder id(String id)

      Unique identifier of the Reservation.

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

      public ReservationBuilder version(Long version)

      Current version of the Reservation.

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

      public ReservationBuilder createdAt(ZonedDateTime createdAt)

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

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

      public ReservationBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

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

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

      public ReservationBuilder expiresAt(ZonedDateTime expiresAt)

      Date and time (UTC) the Reservation will no longer be valid. It can take a few minutes after expiry for the state to be updated to Expired and the stock to be released.

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

      IDs and references that last modified the Reservation.

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

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

      IDs and references that last modified the Reservation.

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

      public ReservationBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the Reservation.

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

      IDs and references that created the Reservation.

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

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

      IDs and references that created the Reservation.

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

      public ReservationBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the Reservation.

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

      Reference to the related InventoryEntry used to manage the inventory.

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

      Reference to the related InventoryEntry used to manage the inventory.

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

      public ReservationBuilder inventoryEntry(InventoryEntryReference inventoryEntry)

      Reference to the related InventoryEntry used to manage the inventory.

      Parameters:
      inventoryEntry - value to be set
      Returns:
      Builder
    • quantity

      public ReservationBuilder quantity(Long quantity)

      The quantity of inventory that is reserved.

      Parameters:
      quantity - value to be set
      Returns:
      Builder
    • owner

      public ReservationBuilder owner(Reference owner)

      Reference to the owner of the Reservation.

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

      public ReservationBuilder owner(Function<ReferenceBuilder,Builder<? extends Reference>> builder)

      Reference to the owner of the Reservation.

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

      public ReservationBuilder lineItemId(String lineItemId)

      Unique identifier of the LineItem this Reservation is associated with.

      Parameters:
      lineItemId - value to be set
      Returns:
      Builder
    • state

      public ReservationBuilder state(ReservationState state)

      Current state of the Reservation.

      Parameters:
      state - value to be set
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the Reservation.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the Reservation.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

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

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

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

      Returns:
      lastModifiedAt
    • getExpiresAt

      public ZonedDateTime getExpiresAt()

      Date and time (UTC) the Reservation will no longer be valid. It can take a few minutes after expiry for the state to be updated to Expired and the stock to be released.

      Returns:
      expiresAt
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the Reservation.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the Reservation.

      Returns:
      createdBy
    • getInventoryEntry

      public InventoryEntryReference getInventoryEntry()

      Reference to the related InventoryEntry used to manage the inventory.

      Returns:
      inventoryEntry
    • getQuantity

      public Long getQuantity()

      The quantity of inventory that is reserved.

      Returns:
      quantity
    • getOwner

      public Reference getOwner()

      Reference to the owner of the Reservation.

      Returns:
      owner
    • getLineItemId

      public String getLineItemId()

      Unique identifier of the LineItem this Reservation is associated with.

      Returns:
      lineItemId
    • getState

      public ReservationState getState()

      Current state of the Reservation.

      Returns:
      state
    • build

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

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

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

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