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

io.sphere.sdk.channels.ChannelDraftBuilder Maven / Gradle / Ivy

The newest version!
package io.sphere.sdk.channels;

import io.sphere.sdk.models.Address;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.models.GeoJSON;
import io.sphere.sdk.models.LocalizedString;
import io.sphere.sdk.types.CustomFieldsDraft;
import io.sphere.sdk.utils.SphereInternalUtils;
import java.lang.String;
import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Generated;
import javax.annotation.Nullable;

/**
 * Builder for {@link ChannelDraft}.
 */
@Generated(
    value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
    comments = "Generated from: io.sphere.sdk.channels.ChannelDraft"
)
public final class ChannelDraftBuilder extends Base implements Builder {
  @Nullable
  private Address address;

  @Nullable
  private CustomFieldsDraft custom;

  @Nullable
  private LocalizedString description;

  @Nullable
  private GeoJSON geoLocation;

  private String key;

  @Nullable
  private LocalizedString name;

  @Nullable
  private Set roles;

  ChannelDraftBuilder() {
  }

  ChannelDraftBuilder(@Nullable final Address address, @Nullable final CustomFieldsDraft custom,
      @Nullable final LocalizedString description, @Nullable final GeoJSON geoLocation,
      final String key, @Nullable final LocalizedString name,
      @Nullable final Set roles) {
    this.address = address;
    this.custom = custom;
    this.description = description;
    this.geoLocation = geoLocation;
    this.key = key;
    this.name = name;
    this.roles = roles;
  }

  /**
   * Sets the {@code address} property of this builder.
   *
   * @param address the value for {@link ChannelDraft#getAddress()}
   * @return this builder
   */
  public ChannelDraftBuilder address(@Nullable final Address address) {
    this.address = address;
    return this;
  }

  /**
   * Sets the {@code custom} property of this builder.
   *
   * @param custom the value for {@link ChannelDraft#getCustom()}
   * @return this builder
   */
  public ChannelDraftBuilder custom(@Nullable final CustomFieldsDraft custom) {
    this.custom = custom;
    return this;
  }

  /**
   * Sets the {@code description} property of this builder.
   *
   * @param description the value for {@link ChannelDraft#getDescription()}
   * @return this builder
   */
  public ChannelDraftBuilder description(@Nullable final LocalizedString description) {
    this.description = description;
    return this;
  }

  /**
   * Sets the {@code geoLocation} property of this builder.
   *
   * @param geoLocation the value for {@link ChannelDraft#getGeoLocation()}
   * @return this builder
   */
  public ChannelDraftBuilder geoLocation(@Nullable final GeoJSON geoLocation) {
    this.geoLocation = geoLocation;
    return this;
  }

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

  /**
   * Sets the {@code name} property of this builder.
   *
   * @param name the value for {@link ChannelDraft#getName()}
   * @return this builder
   */
  public ChannelDraftBuilder name(@Nullable final LocalizedString name) {
    this.name = name;
    return this;
  }

  /**
   * Sets the {@code roles} property of this builder.
   *
   * @param roles the value for {@link ChannelDraft#getRoles()}
   * @return this builder
   */
  public ChannelDraftBuilder roles(@Nullable final Set roles) {
    this.roles = roles;
    return this;
  }

  @Nullable
  public Address getAddress() {
    return address;
  }

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

  @Nullable
  public LocalizedString getDescription() {
    return description;
  }

  @Nullable
  public GeoJSON getGeoLocation() {
    return geoLocation;
  }

  public String getKey() {
    return key;
  }

  @Nullable
  public LocalizedString getName() {
    return name;
  }

  @Nullable
  public Set getRoles() {
    return roles;
  }

  /**
   * Concatenate {@code roles} parameter to the {@code roles} set property of this builder.
   *
   * @param roles the value for {@link ChannelDraft#getRoles()}
   * @return this builder
   */
  public ChannelDraftBuilder plusRoles(final Set roles) {
    this.roles =  SphereInternalUtils.setOf(Optional.ofNullable(this.roles).orElseGet(HashSet::new), roles);
    return this;
  }

  /**
   * Adds {@code roles} parameter to the {@code roles} set property of this builder.
   *
   * @param roles the value of the element to add to {@link ChannelDraft#getRoles()}
   * @return this builder
   */
  public ChannelDraftBuilder plusRoles(final ChannelRole roles) {
    this.roles =  SphereInternalUtils.setOf(Collections.singleton(roles), Optional.ofNullable(this.roles).orElseGet(HashSet::new));
    return this;
  }

  /**
   * Creates a new instance of {@code ChannelDraftDsl} with the values of this builder.
   *
   * @return the instance
   */
  public ChannelDraftDsl build() {
    return new ChannelDraftDsl(address, custom, description, geoLocation, key, name, roles);
  }

  /**
   * Creates a new object initialized with the given values.
   *
   * @param key initial value for the {@link ChannelDraft#getKey()} property
   * @return new object initialized with the given values
   */
  public static ChannelDraftBuilder of(final String key) {
    return new ChannelDraftBuilder(null, null, null, null, key, null, null);
  }

  /**
   * 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 ChannelDraftBuilder of(final ChannelDraft template) {
    return new ChannelDraftBuilder(template.getAddress(), template.getCustom(), template.getDescription(), template.getGeoLocation(), template.getKey(), template.getName(), template.getRoles());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy