io.sphere.sdk.zones.ZoneDraftBuilder Maven / Gradle / Ivy
The newest version!
package io.sphere.sdk.zones;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
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 ZoneDraft}.
*/
@Generated(
value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
comments = "Generated from: io.sphere.sdk.zones.ZoneDraft"
)
public final class ZoneDraftBuilder extends Base implements Builder {
@Nullable
private String description;
@Nullable
private String key;
private Set locations;
private String name;
ZoneDraftBuilder() {
}
ZoneDraftBuilder(@Nullable final String description, @Nullable final String key,
final Set locations, final String name) {
this.description = description;
this.key = key;
this.locations = locations;
this.name = name;
}
/**
* Sets the {@code description} property of this builder.
*
* @param description the value for {@link ZoneDraft#getDescription()}
* @return this builder
*/
public ZoneDraftBuilder description(@Nullable final String description) {
this.description = description;
return this;
}
/**
* Sets the {@code key} property of this builder.
*
* @param key the value for {@link ZoneDraft#getKey()}
* @return this builder
*/
public ZoneDraftBuilder key(@Nullable final String key) {
this.key = key;
return this;
}
/**
* Sets the {@code locations} property of this builder.
*
* @param locations the value for {@link ZoneDraft#getLocations()}
* @return this builder
*/
public ZoneDraftBuilder locations(final Set locations) {
this.locations = locations;
return this;
}
/**
* Sets the {@code name} property of this builder.
*
* @param name the value for {@link ZoneDraft#getName()}
* @return this builder
*/
public ZoneDraftBuilder name(final String name) {
this.name = name;
return this;
}
@Nullable
public String getDescription() {
return description;
}
@Nullable
public String getKey() {
return key;
}
public Set getLocations() {
return locations;
}
public String getName() {
return name;
}
/**
* Concatenate {@code locations} parameter to the {@code locations} set property of this builder.
*
* @param locations the value for {@link ZoneDraft#getLocations()}
* @return this builder
*/
public ZoneDraftBuilder plusLocations(final Set locations) {
this.locations = SphereInternalUtils.setOf(Optional.ofNullable(this.locations).orElseGet(HashSet::new), locations);
return this;
}
/**
* Adds {@code locations} parameter to the {@code locations} set property of this builder.
*
* @param locations the value of the element to add to {@link ZoneDraft#getLocations()}
* @return this builder
*/
public ZoneDraftBuilder plusLocations(final Location locations) {
this.locations = SphereInternalUtils.setOf(Collections.singleton(locations), Optional.ofNullable(this.locations).orElseGet(HashSet::new));
return this;
}
/**
* Creates a new instance of {@code ZoneDraftDsl} with the values of this builder.
*
* @return the instance
*/
public ZoneDraftDsl build() {
return new ZoneDraftDsl(description, key, locations, name);
}
/**
* Creates a new object initialized with the given values.
*
* @param name initial value for the {@link ZoneDraft#getName()} property
* @param locations initial value for the {@link ZoneDraft#getLocations()} property
* @param description initial value for the {@link ZoneDraft#getDescription()} property
* @return new object initialized with the given values
*/
public static ZoneDraftBuilder of(final String name, final Set locations,
@Nullable final String description) {
return new ZoneDraftBuilder(description, null, locations, name);
}
/**
* Creates a new object initialized with the given values.
*
* @param name initial value for the {@link ZoneDraft#getName()} property
* @param locations initial value for the {@link ZoneDraft#getLocations()} property
* @return new object initialized with the given values
*/
public static ZoneDraftBuilder of(final String name, final Set locations) {
return new ZoneDraftBuilder(null, null, locations, name);
}
/**
* 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 ZoneDraftBuilder of(final ZoneDraft template) {
return new ZoneDraftBuilder(template.getDescription(), template.getKey(), template.getLocations(), template.getName());
}
}