Class TransactionBuilder

java.lang.Object
com.commercetools.history.models.common.TransactionBuilder
All Implemented Interfaces:
Builder<Transaction>

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

     Transaction transaction = Transaction.builder()
             .id("{id}")
             .timestamp("{timestamp}")
             .type(TransactionType.AUTHORIZATION)
             .amount(amountBuilder -> amountBuilder)
             .interactionId("{interactionId}")
             .state(TransactionState.INITIAL)
             .build()
 
  • Constructor Details

    • TransactionBuilder

      public TransactionBuilder()
  • Method Details

    • id

      public TransactionBuilder id(String id)

      Unique identifier of the Transaction.

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

      public TransactionBuilder timestamp(String timestamp)

      Time at which the transaction took place.

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

      public TransactionBuilder type(TransactionType type)
      set the value to the type
      Parameters:
      type - value to be set
      Returns:
      Builder
    • amount

      set the value to the amount using the builder function
      Parameters:
      builder - function to build the amount value
      Returns:
      Builder
    • withAmount

      public TransactionBuilder withAmount(Function<MoneyBuilder,Money> builder)
      set the value to the amount using the builder function
      Parameters:
      builder - function to build the amount value
      Returns:
      Builder
    • amount

      public TransactionBuilder amount(Money amount)
      set the value to the amount
      Parameters:
      amount - value to be set
      Returns:
      Builder
    • interactionId

      public TransactionBuilder interactionId(String interactionId)

      Identifier used by the interface that manages the transaction (usually the PSP). If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction should be findable with this ID.

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

      public TransactionBuilder state(TransactionState state)
      set the value to the state
      Parameters:
      state - value to be set
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the Transaction.

      Returns:
      id
    • getTimestamp

      public String getTimestamp()

      Time at which the transaction took place.

      Returns:
      timestamp
    • getType

      public TransactionType getType()
      value of type}
      Returns:
      type
    • getAmount

      public Money getAmount()
      value of amount}
      Returns:
      amount
    • getInteractionId

      public String getInteractionId()

      Identifier used by the interface that manages the transaction (usually the PSP). If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction should be findable with this ID.

      Returns:
      interactionId
    • getState

      public TransactionState getState()
      value of state}
      Returns:
      state
    • build

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

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

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

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