com.commercetools.importapi.models.common.PriceTierBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-sdk-java-importapi Show documentation
Show all versions of commercetools-sdk-java-importapi Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
package com.commercetools.importapi.models.common;
import java.util.*;
import java.util.function.Function;
import io.vrap.rmf.base.client.Builder;
import io.vrap.rmf.base.client.utils.Generated;
/**
* PriceTierBuilder
*
* Example to create an instance using the builder pattern
*
*
* PriceTier priceTier = PriceTier.builder()
* .minimumQuantity(0.3)
* .value(valueBuilder -> valueBuilder)
* .build()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class PriceTierBuilder implements Builder {
private Long minimumQuantity;
private com.commercetools.importapi.models.common.TypedMoney value;
/**
* The minimum quantity this price tier is valid for.
* @param minimumQuantity value to be set
* @return Builder
*/
public PriceTierBuilder minimumQuantity(final Long minimumQuantity) {
this.minimumQuantity = minimumQuantity;
return this;
}
/**
* The currency of a price tier is always the same as the currency of the base Price.
* @param value value to be set
* @return Builder
*/
public PriceTierBuilder value(final com.commercetools.importapi.models.common.TypedMoney value) {
this.value = value;
return this;
}
/**
* The currency of a price tier is always the same as the currency of the base Price.
* @param builder function to build the value value
* @return Builder
*/
public PriceTierBuilder value(
Function> builder) {
this.value = builder.apply(com.commercetools.importapi.models.common.TypedMoneyBuilder.of()).build();
return this;
}
/**
* The minimum quantity this price tier is valid for.
* @return minimumQuantity
*/
public Long getMinimumQuantity() {
return this.minimumQuantity;
}
/**
* The currency of a price tier is always the same as the currency of the base Price.
* @return value
*/
public com.commercetools.importapi.models.common.TypedMoney getValue() {
return this.value;
}
/**
* builds PriceTier with checking for non-null required values
* @return PriceTier
*/
public PriceTier build() {
Objects.requireNonNull(minimumQuantity, PriceTier.class + ": minimumQuantity is missing");
Objects.requireNonNull(value, PriceTier.class + ": value is missing");
return new PriceTierImpl(minimumQuantity, value);
}
/**
* builds PriceTier without checking for non-null required values
* @return PriceTier
*/
public PriceTier buildUnchecked() {
return new PriceTierImpl(minimumQuantity, value);
}
/**
* factory method for an instance of PriceTierBuilder
* @return builder
*/
public static PriceTierBuilder of() {
return new PriceTierBuilder();
}
/**
* create builder for PriceTier instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static PriceTierBuilder of(final PriceTier template) {
PriceTierBuilder builder = new PriceTierBuilder();
builder.minimumQuantity = template.getMinimumQuantity();
builder.value = template.getValue();
return builder;
}
}