com.commercetools.history.models.common.CustomFieldsBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-sdk-java-history Show documentation
Show all versions of commercetools-sdk-java-history Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
package com.commercetools.history.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;
/**
* CustomFieldsBuilder
*
* Example to create an instance using the builder pattern
*
*
* CustomFields customFields = CustomFields.builder()
* .type(typeBuilder -> typeBuilder)
* .fields(fieldsBuilder -> fieldsBuilder)
* .build()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class CustomFieldsBuilder implements Builder {
private com.commercetools.history.models.common.Reference type;
private java.lang.Object fields;
/**
* set the value to the type using the builder function
* @param builder function to build the type value
* @return Builder
*/
public CustomFieldsBuilder type(
Function builder) {
this.type = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build();
return this;
}
/**
* set the value to the type using the builder function
* @param builder function to build the type value
* @return Builder
*/
public CustomFieldsBuilder withType(
Function builder) {
this.type = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of());
return this;
}
/**
* set the value to the type
* @param type value to be set
* @return Builder
*/
public CustomFieldsBuilder type(final com.commercetools.history.models.common.Reference type) {
this.type = type;
return this;
}
/**
* A valid JSON object, based on FieldDefinition.
* @param fields value to be set
* @return Builder
*/
public CustomFieldsBuilder fields(final java.lang.Object fields) {
this.fields = fields;
return this;
}
/**
* value of type}
* @return type
*/
public com.commercetools.history.models.common.Reference getType() {
return this.type;
}
/**
* A valid JSON object, based on FieldDefinition.
* @return fields
*/
public java.lang.Object getFields() {
return this.fields;
}
/**
* builds CustomFields with checking for non-null required values
* @return CustomFields
*/
public CustomFields build() {
Objects.requireNonNull(type, CustomFields.class + ": type is missing");
Objects.requireNonNull(fields, CustomFields.class + ": fields is missing");
return new CustomFieldsImpl(type, fields);
}
/**
* builds CustomFields without checking for non-null required values
* @return CustomFields
*/
public CustomFields buildUnchecked() {
return new CustomFieldsImpl(type, fields);
}
/**
* factory method for an instance of CustomFieldsBuilder
* @return builder
*/
public static CustomFieldsBuilder of() {
return new CustomFieldsBuilder();
}
/**
* create builder for CustomFields instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static CustomFieldsBuilder of(final CustomFields template) {
CustomFieldsBuilder builder = new CustomFieldsBuilder();
builder.type = template.getType();
builder.fields = template.getFields();
return builder;
}
}