All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.payments.TransactionDraftDslBase Maven / Gradle / Ivy

There is a newer version: 2.16.0
Show newest version
package io.sphere.sdk.payments;

import com.fasterxml.jackson.annotation.JsonCreator;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.types.CustomFields;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.time.ZonedDateTime;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.money.MonetaryAmount;

/**
 * Abstract base dsl class for {@link TransactionDraft} which needs to be extended to add additional methods.
 * Subclasses have to provide the same non-default constructor as this class.
 */
@Generated(
    value = "io.sphere.sdk.annotations.processors.generators.ResourceDraftValueGenerator",
    comments = "Generated from: io.sphere.sdk.payments.TransactionDraft"
)
abstract class TransactionDraftDslBase extends Base implements TransactionDraft {
  private MonetaryAmount amount;

  @Nullable
  private CustomFields custom;

  @Nullable
  private String interactionId;

  @Nullable
  private TransactionState state;

  @Nullable
  private ZonedDateTime timestamp;

  private TransactionType type;

  @JsonCreator
  TransactionDraftDslBase(final MonetaryAmount amount, @Nullable final CustomFields custom,
      @Nullable final String interactionId, @Nullable final TransactionState state,
      @Nullable final ZonedDateTime timestamp, final TransactionType type) {
    this.amount = amount;
    this.custom = custom;
    this.interactionId = interactionId;
    this.state = state;
    this.timestamp = timestamp;
    this.type = type;
  }

  public MonetaryAmount getAmount() {
    return amount;
  }

  @Nullable
  public CustomFields getCustom() {
    return custom;
  }

  @Nullable
  public String getInteractionId() {
    return interactionId;
  }

  @Nullable
  public TransactionState getState() {
    return state;
  }

  @Nullable
  public ZonedDateTime getTimestamp() {
    return timestamp;
  }

  public TransactionType getType() {
    return type;
  }

  /**
   * Creates a new builder with the values of this object.
   *
   * @return new builder
   */
  public TransactionDraftBuilder newBuilder() {
    return new TransactionDraftBuilder(amount, custom, interactionId, state, timestamp, type);
  }

  @SuppressWarnings("unchecked")
  public T withAmount(final MonetaryAmount amount) {
    return (T) newBuilder().amount(amount).build();
  }

  @SuppressWarnings("unchecked")
  public T withCustom(@Nullable final CustomFields custom) {
    return (T) newBuilder().custom(custom).build();
  }

  @SuppressWarnings("unchecked")
  public T withInteractionId(@Nullable final String interactionId) {
    return (T) newBuilder().interactionId(interactionId).build();
  }

  @SuppressWarnings("unchecked")
  public T withState(@Nullable final TransactionState state) {
    return (T) newBuilder().state(state).build();
  }

  @SuppressWarnings("unchecked")
  public T withTimestamp(@Nullable final ZonedDateTime timestamp) {
    return (T) newBuilder().timestamp(timestamp).build();
  }

  @SuppressWarnings("unchecked")
  public T withType(final TransactionType type) {
    return (T) newBuilder().type(type).build();
  }

  /**
   * Creates a new object initialized with the given values.
   *
   * @param type initial value for the {@link TransactionDraft#getType()} property
   * @param amount initial value for the {@link TransactionDraft#getAmount()} property
   * @return new object initialized with the given values
   */
  public static TransactionDraftDsl of(final TransactionType type, final MonetaryAmount amount) {
    return new TransactionDraftDsl(amount, null, null, null, null, type);
  }

  /**
   * Creates a new object initialized with the given values.
   *
   * @param type initial value for the {@link TransactionDraft#getType()} property
   * @param amount initial value for the {@link TransactionDraft#getAmount()} property
   * @param timestamp initial value for the {@link TransactionDraft#getTimestamp()} property
   * @return new object initialized with the given values
   */
  public static TransactionDraftDsl of(final TransactionType type, final MonetaryAmount amount,
      @Nullable final ZonedDateTime timestamp) {
    return new TransactionDraftDsl(amount, null, null, null, timestamp, type);
  }

  /**
   * Creates a new object initialized with the fields of the template parameter.
   *
   * @param template the template
   * @return a new object initialized from the template
   */
  public static TransactionDraftDsl of(final TransactionDraft template) {
    return new TransactionDraftDsl(template.getAmount(), template.getCustom(), template.getInteractionId(), template.getState(), template.getTimestamp(), template.getType());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy