com.commercetools.history.models.common.Transaction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-sdk-java-history Show documentation
Show all versions of commercetools-sdk-java-history Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
package com.commercetools.history.models.common;
import java.time.*;
import java.util.*;
import java.util.function.Function;
import javax.annotation.Nullable;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.*;
import io.vrap.rmf.base.client.utils.Generated;
/**
* Transaction
*
*
* 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()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
@JsonDeserialize(as = TransactionImpl.class)
public interface Transaction {
/**
* Unique identifier of the Transaction.
* @return id
*/
@NotNull
@JsonProperty("id")
public String getId();
/**
* Time at which the transaction took place.
* @return timestamp
*/
@NotNull
@JsonProperty("timestamp")
public String getTimestamp();
/**
*
* @return type
*/
@NotNull
@JsonProperty("type")
public TransactionType getType();
/**
*
* @return amount
*/
@NotNull
@Valid
@JsonProperty("amount")
public Money getAmount();
/**
* 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.
* @return interactionId
*/
@NotNull
@JsonProperty("interactionId")
public String getInteractionId();
/**
*
* @return state
*/
@NotNull
@JsonProperty("state")
public TransactionState getState();
/**
* Unique identifier of the Transaction.
* @param id value to be set
*/
public void setId(final String id);
/**
* Time at which the transaction took place.
* @param timestamp value to be set
*/
public void setTimestamp(final String timestamp);
/**
* set type
* @param type value to be set
*/
public void setType(final TransactionType type);
/**
* set amount
* @param amount value to be set
*/
public void setAmount(final Money amount);
/**
* 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.
* @param interactionId value to be set
*/
public void setInteractionId(final String interactionId);
/**
* set state
* @param state value to be set
*/
public void setState(final TransactionState state);
/**
* factory method
* @return instance of Transaction
*/
public static Transaction of() {
return new TransactionImpl();
}
/**
* factory method to create a shallow copy Transaction
* @param template instance to be copied
* @return copy instance
*/
public static Transaction of(final Transaction template) {
TransactionImpl instance = new TransactionImpl();
instance.setId(template.getId());
instance.setTimestamp(template.getTimestamp());
instance.setType(template.getType());
instance.setAmount(template.getAmount());
instance.setInteractionId(template.getInteractionId());
instance.setState(template.getState());
return instance;
}
/**
* factory method to create a deep copy of Transaction
* @param template instance to be copied
* @return copy instance
*/
@Nullable
public static Transaction deepCopy(@Nullable final Transaction template) {
if (template == null) {
return null;
}
TransactionImpl instance = new TransactionImpl();
instance.setId(template.getId());
instance.setTimestamp(template.getTimestamp());
instance.setType(template.getType());
instance.setAmount(com.commercetools.history.models.common.Money.deepCopy(template.getAmount()));
instance.setInteractionId(template.getInteractionId());
instance.setState(template.getState());
return instance;
}
/**
* builder factory method for Transaction
* @return builder
*/
public static TransactionBuilder builder() {
return TransactionBuilder.of();
}
/**
* create builder for Transaction instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static TransactionBuilder builder(final Transaction template) {
return TransactionBuilder.of(template);
}
/**
* accessor map function
* @param mapped type
* @param helper function to map the object
* @return mapped value
*/
default T withTransaction(Function helper) {
return helper.apply(this);
}
/**
* gives a TypeReference for usage with Jackson DataBind
* @return TypeReference
*/
public static com.fasterxml.jackson.core.type.TypeReference typeReference() {
return new com.fasterxml.jackson.core.type.TypeReference() {
@Override
public String toString() {
return "TypeReference";
}
};
}
}