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

io.sphere.sdk.extensions.ExtensionDraftBuilder Maven / Gradle / Ivy

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

import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.utils.SphereInternalUtils;
import java.lang.Long;
import java.lang.String;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import javax.annotation.Nullable;

/**
 * Builder for {@link ExtensionDraft}.
 */
@Generated(
    value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
    comments = "Generated from: io.sphere.sdk.extensions.ExtensionDraft"
)
public final class ExtensionDraftBuilder extends Base implements Builder {
  private Destination destination;

  @Nullable
  private String key;

  @Nullable
  private Long timeoutInMs;

  private List triggers;

  ExtensionDraftBuilder() {
  }

  ExtensionDraftBuilder(final Destination destination, @Nullable final String key,
      @Nullable final Long timeoutInMs, final List triggers) {
    this.destination = destination;
    this.key = key;
    this.timeoutInMs = timeoutInMs;
    this.triggers = triggers;
  }

  /**
   * Sets the {@code destination} property of this builder.
   *
   * @param destination the value for {@link ExtensionDraft#getDestination()}
   * @return this builder
   */
  public ExtensionDraftBuilder destination(final Destination destination) {
    this.destination = destination;
    return this;
  }

  /**
   * Sets the {@code key} property of this builder.
   *
   * @param key the value for {@link ExtensionDraft#getKey()}
   * @return this builder
   */
  public ExtensionDraftBuilder key(@Nullable final String key) {
    this.key = key;
    return this;
  }

  /**
   * Sets the {@code timeoutInMs} property of this builder.
   *
   * @param timeoutInMs the value for {@link ExtensionDraft#getTimeoutInMs()}
   * @return this builder
   */
  public ExtensionDraftBuilder timeoutInMs(@Nullable final Long timeoutInMs) {
    this.timeoutInMs = timeoutInMs;
    return this;
  }

  /**
   * Sets the {@code triggers} property of this builder.
   *
   * @param triggers the value for {@link ExtensionDraft#getTriggers()}
   * @return this builder
   */
  public ExtensionDraftBuilder triggers(final List triggers) {
    this.triggers = triggers;
    return this;
  }

  public Destination getDestination() {
    return destination;
  }

  @Nullable
  public String getKey() {
    return key;
  }

  @Nullable
  public Long getTimeoutInMs() {
    return timeoutInMs;
  }

  public List getTriggers() {
    return triggers;
  }

  /**
   * Concatenate {@code triggers} parameter to the {@code triggers} list property of this builder.
   *
   * @param triggers the value for {@link ExtensionDraft#getTriggers()}
   * @return this builder
   */
  public ExtensionDraftBuilder plusTriggers(final List triggers) {
    this.triggers =  SphereInternalUtils.listOf(Optional.ofNullable(this.triggers).orElseGet(ArrayList::new), triggers);
    return this;
  }

  /**
   * Adds {@code triggers} parameter to the {@code triggers} list property of this builder.
   *
   * @param triggers the value of the element to add to {@link ExtensionDraft#getTriggers()}
   * @return this builder
   */
  public ExtensionDraftBuilder plusTriggers(final Trigger triggers) {
    this.triggers =  SphereInternalUtils.listOf(Optional.ofNullable(this.triggers).orElseGet(ArrayList::new), Collections.singletonList(triggers));
    return this;
  }

  /**
   * Creates a new instance of {@code ExtensionDraftDsl} with the values of this builder.
   *
   * @return the instance
   */
  public ExtensionDraftDsl build() {
    return new ExtensionDraftDsl(destination, key, timeoutInMs, triggers);
  }

  /**
   * Creates a new object initialized with the given values.
   *
   * @param key initial value for the {@link ExtensionDraft#getKey()} property
   * @param destination initial value for the {@link ExtensionDraft#getDestination()} property
   * @param triggers initial value for the {@link ExtensionDraft#getTriggers()} property
   * @param timeoutInMs initial value for the {@link ExtensionDraft#getTimeoutInMs()} property
   * @return new object initialized with the given values
   */
  public static ExtensionDraftBuilder of(@Nullable final String key, final Destination destination,
      final List triggers, @Nullable final Long timeoutInMs) {
    return new ExtensionDraftBuilder(destination, key, timeoutInMs, triggers);
  }

  /**
   * Creates a new object initialized with the given values.
   *
   * @param key initial value for the {@link ExtensionDraft#getKey()} property
   * @param destination initial value for the {@link ExtensionDraft#getDestination()} property
   * @param triggers initial value for the {@link ExtensionDraft#getTriggers()} property
   * @return new object initialized with the given values
   */
  public static ExtensionDraftBuilder of(@Nullable final String key, final Destination destination,
      final List triggers) {
    return new ExtensionDraftBuilder(destination, key, null, triggers);
  }

  /**
   * Creates a new object initialized with the given values.
   *
   * @param destination initial value for the {@link ExtensionDraft#getDestination()} property
   * @param triggers initial value for the {@link ExtensionDraft#getTriggers()} property
   * @return new object initialized with the given values
   */
  public static ExtensionDraftBuilder of(final Destination destination,
      final List triggers) {
    return new ExtensionDraftBuilder(destination, null, null, triggers);
  }

  /**
   * 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 ExtensionDraftBuilder of(final ExtensionDraft template) {
    return new ExtensionDraftBuilder(template.getDestination(), template.getKey(), template.getTimeoutInMs(), template.getTriggers());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy