io.sphere.sdk.shippingmethods.ZoneRateDraftBuilder Maven / Gradle / Ivy
package io.sphere.sdk.shippingmethods;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.models.ResourceIdentifier;
import io.sphere.sdk.utils.SphereInternalUtils;
import io.sphere.sdk.zones.Zone;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
/**
* Builder for {@link ZoneRateDraft}.
*/
@Generated(
value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
comments = "Generated from: io.sphere.sdk.shippingmethods.ZoneRateDraft"
)
public final class ZoneRateDraftBuilder extends Base implements Builder {
private List shippingRates;
private ResourceIdentifier zone;
ZoneRateDraftBuilder() {
}
ZoneRateDraftBuilder(final List shippingRates,
final ResourceIdentifier zone) {
this.shippingRates = shippingRates;
this.zone = zone;
}
/**
* Sets the {@code shippingRates} property of this builder.
*
* @param shippingRates the value for {@link ZoneRateDraft#getShippingRates()}
* @return this builder
*/
public ZoneRateDraftBuilder shippingRates(final List shippingRates) {
this.shippingRates = shippingRates;
return this;
}
/**
* Sets the {@code zone} property of this builder.
*
* @param zone the value for {@link ZoneRateDraft#getZone()}
* @return this builder
*/
public ZoneRateDraftBuilder zone(final ResourceIdentifier zone) {
this.zone = zone;
return this;
}
public List getShippingRates() {
return shippingRates;
}
public ResourceIdentifier getZone() {
return zone;
}
/**
* Concatenate {@code shippingRates} parameter to the {@code shippingRates} list property of this builder.
*
* @param shippingRates the value for {@link ZoneRateDraft#getShippingRates()}
* @return this builder
*/
public ZoneRateDraftBuilder plusShippingRates(final List shippingRates) {
this.shippingRates = SphereInternalUtils.listOf(Optional.ofNullable(this.shippingRates).orElseGet(ArrayList::new), shippingRates);
return this;
}
/**
* Adds {@code shippingRates} parameter to the {@code shippingRates} list property of this builder.
*
* @param shippingRates the value of the element to add to {@link ZoneRateDraft#getShippingRates()}
* @return this builder
*/
public ZoneRateDraftBuilder plusShippingRates(final ShippingRate shippingRates) {
this.shippingRates = SphereInternalUtils.listOf(Optional.ofNullable(this.shippingRates).orElseGet(ArrayList::new), Collections.singletonList(shippingRates));
return this;
}
/**
* Creates a new instance of {@code ZoneRateDraftDsl} with the values of this builder.
*
* @return the instance
*/
public ZoneRateDraftDsl build() {
return new ZoneRateDraftDsl(shippingRates, zone);
}
/**
* Creates a new object initialized with the given values.
*
* @param zone initial value for the {@link ZoneRateDraft#getZone()} property
* @param shippingRates initial value for the {@link ZoneRateDraft#getShippingRates()} property
* @return new object initialized with the given values
*/
public static ZoneRateDraftBuilder of(final ResourceIdentifier zone,
final List shippingRates) {
return new ZoneRateDraftBuilder(shippingRates, zone);
}
/**
* 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 ZoneRateDraftBuilder of(final ZoneRateDraft template) {
return new ZoneRateDraftBuilder(template.getShippingRates(), template.getZone());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy