Class TransactionBuilder
java.lang.Object
com.commercetools.history.models.common.TransactionBuilder
- All Implemented Interfaces:
Builder<Transaction>
TransactionBuilder
Example to create an instance using the builder pattern
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionset the value to the amountamount
(Function<MoneyBuilder, MoneyBuilder> builder) set the value to the amount using the builder functionbuild()
builds Transaction with checking for non-null required valuesbuilds Transaction without checking for non-null required valuesvalue of amount}getId()
Unique identifier of the Transaction.Identifier used by the interface that manages the transaction (usually the PSP).getState()
value of state}Time at which the transaction took place.getType()
value of type}Unique identifier of the Transaction.interactionId
(String interactionId) Identifier used by the interface that manages the transaction (usually the PSP).static TransactionBuilder
of()
factory method for an instance of TransactionBuilderstatic TransactionBuilder
of
(Transaction template) create builder for Transaction instancestate
(TransactionState state) set the value to the stateTime at which the transaction took place.type
(TransactionType type) set the value to the typewithAmount
(Function<MoneyBuilder, Money> builder) set the value to the amount using the builder function
-
Constructor Details
-
TransactionBuilder
public TransactionBuilder()
-
-
Method Details
-
id
Unique identifier of the Transaction.
- Parameters:
id
- value to be set- Returns:
- Builder
-
timestamp
Time at which the transaction took place.
- Parameters:
timestamp
- value to be set- Returns:
- Builder
-
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
set the value to the amount using the builder function- Parameters:
builder
- function to build the amount value- Returns:
- Builder
-
amount
set the value to the amount- Parameters:
amount
- value to be set- Returns:
- Builder
-
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
set the value to the state- Parameters:
state
- value to be set- Returns:
- Builder
-
getId
Unique identifier of the Transaction.
- Returns:
- id
-
getTimestamp
Time at which the transaction took place.
- Returns:
- timestamp
-
getType
value of type}- Returns:
- type
-
getAmount
value of amount}- Returns:
- amount
-
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
value of state}- Returns:
- state
-
build
builds Transaction with checking for non-null required values- Specified by:
build
in interfaceBuilder<Transaction>
- Returns:
- Transaction
-
buildUnchecked
builds Transaction without checking for non-null required values- Returns:
- Transaction
-
of
factory method for an instance of TransactionBuilder- Returns:
- builder
-
of
create builder for Transaction instance- Parameters:
template
- instance with prefilled values for the builder- Returns:
- builder
-