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

io.sphere.sdk.carts.ItemShippingDetailsDraftBuilder Maven / Gradle / Ivy

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

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

/**
 * Builder for {@link ItemShippingDetailsDraft}.
 */
@Generated(
    value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
    comments = "Generated from: io.sphere.sdk.carts.ItemShippingDetailsDraft"
)
public final class ItemShippingDetailsDraftBuilder extends Base implements Builder {
  private List targets;

  ItemShippingDetailsDraftBuilder() {
  }

  ItemShippingDetailsDraftBuilder(final List targets) {
    this.targets = targets;
  }

  /**
   * Sets the {@code targets} property of this builder.
   *
   * @param targets the value for {@link ItemShippingDetailsDraft#getTargets()}
   * @return this builder
   */
  public ItemShippingDetailsDraftBuilder targets(final List targets) {
    this.targets = targets;
    return this;
  }

  public List getTargets() {
    return targets;
  }

  /**
   * Concatenate {@code targets} parameter to the {@code targets} list property of this builder.
   *
   * @param targets the value for {@link ItemShippingDetailsDraft#getTargets()}
   * @return this builder
   */
  public ItemShippingDetailsDraftBuilder plusTargets(final List targets) {
    this.targets =  SphereInternalUtils.listOf(Optional.ofNullable(this.targets).orElseGet(ArrayList::new), targets);
    return this;
  }

  /**
   * Adds {@code targets} parameter to the {@code targets} list property of this builder.
   *
   * @param targets the value of the element to add to {@link ItemShippingDetailsDraft#getTargets()}
   * @return this builder
   */
  public ItemShippingDetailsDraftBuilder plusTargets(final ItemShippingTarget targets) {
    this.targets =  SphereInternalUtils.listOf(Optional.ofNullable(this.targets).orElseGet(ArrayList::new), Collections.singletonList(targets));
    return this;
  }

  /**
   * Creates a new instance of {@code ItemShippingDetailsDraftDsl} with the values of this builder.
   *
   * @return the instance
   */
  public ItemShippingDetailsDraftDsl build() {
    return new ItemShippingDetailsDraftDsl(targets);
  }

  /**
   * Creates a new object initialized with the given values.
   *
   * @param targets initial value for the {@link ItemShippingDetailsDraft#getTargets()} property
   * @return new object initialized with the given values
   */
  public static ItemShippingDetailsDraftBuilder of(final List targets) {
    return new ItemShippingDetailsDraftBuilder(targets);
  }

  /**
   * 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 ItemShippingDetailsDraftBuilder of(final ItemShippingDetailsDraft template) {
    return new ItemShippingDetailsDraftBuilder(template.getTargets());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy