com.arakelian.elastic.bulk.ImmutableSimpleBulkOperationFactory Maven / Gradle / Ivy
package com.arakelian.elastic.bulk;
import com.arakelian.core.feature.Nullable;
import com.arakelian.elastic.doc.ElasticDocBuilder;
import com.arakelian.elastic.model.Index;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link SimpleBulkOperationFactory}.
*
* Use the builder to create immutable instances:
* {@code ImmutableSimpleBulkOperationFactory.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableSimpleBulkOperationFactory
extends SimpleBulkOperationFactory {
private final Function deleteVersion;
private final Class documentClass;
private final @Nullable ElasticDocBuilder elasticDocBuilder;
private final Function elasticDocument;
private final Function id;
private final Index index;
private final Function json;
private final Predicate predicate;
private final Function type;
private final Function version;
private ImmutableSimpleBulkOperationFactory(ImmutableSimpleBulkOperationFactory.Builder builder) {
this.documentClass = builder.documentClass;
this.elasticDocBuilder = builder.elasticDocBuilder;
this.id = builder.id;
this.index = builder.index;
this.version = builder.version;
if (builder.deleteVersion != null) {
initShim.deleteVersion(builder.deleteVersion);
}
if (builder.elasticDocument != null) {
initShim.elasticDocument(builder.elasticDocument);
}
if (builder.json != null) {
initShim.json(builder.json);
}
if (builder.predicate != null) {
initShim.predicate(builder.predicate);
}
if (builder.type != null) {
initShim.type(builder.type);
}
this.deleteVersion = initShim.getDeleteVersion();
this.elasticDocument = initShim.getElasticDocument();
this.json = initShim.getJson();
this.predicate = initShim.getPredicate();
this.type = initShim.getType();
this.initShim = null;
}
private ImmutableSimpleBulkOperationFactory(
Function deleteVersion,
Class documentClass,
@Nullable ElasticDocBuilder elasticDocBuilder,
Function elasticDocument,
Function id,
Index index,
Function json,
Predicate predicate,
Function type,
Function version) {
this.deleteVersion = deleteVersion;
this.documentClass = documentClass;
this.elasticDocBuilder = elasticDocBuilder;
this.elasticDocument = elasticDocument;
this.id = id;
this.index = index;
this.json = json;
this.predicate = predicate;
this.type = type;
this.version = version;
this.initShim = null;
}
private static final byte STAGE_INITIALIZING = -1;
private static final byte STAGE_UNINITIALIZED = 0;
private static final byte STAGE_INITIALIZED = 1;
@SuppressWarnings("Immutable")
private transient volatile InitShim initShim = new InitShim();
private final class InitShim {
private byte deleteVersionBuildStage = STAGE_UNINITIALIZED;
private Function deleteVersion;
Function getDeleteVersion() {
if (deleteVersionBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (deleteVersionBuildStage == STAGE_UNINITIALIZED) {
deleteVersionBuildStage = STAGE_INITIALIZING;
this.deleteVersion = Objects.requireNonNull(ImmutableSimpleBulkOperationFactory.super.getDeleteVersion(), "deleteVersion");
deleteVersionBuildStage = STAGE_INITIALIZED;
}
return this.deleteVersion;
}
void deleteVersion(Function deleteVersion) {
this.deleteVersion = deleteVersion;
deleteVersionBuildStage = STAGE_INITIALIZED;
}
private byte elasticDocumentBuildStage = STAGE_UNINITIALIZED;
private Function elasticDocument;
Function getElasticDocument() {
if (elasticDocumentBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (elasticDocumentBuildStage == STAGE_UNINITIALIZED) {
elasticDocumentBuildStage = STAGE_INITIALIZING;
this.elasticDocument = Objects.requireNonNull(ImmutableSimpleBulkOperationFactory.super.getElasticDocument(), "elasticDocument");
elasticDocumentBuildStage = STAGE_INITIALIZED;
}
return this.elasticDocument;
}
void elasticDocument(Function elasticDocument) {
this.elasticDocument = elasticDocument;
elasticDocumentBuildStage = STAGE_INITIALIZED;
}
private byte jsonBuildStage = STAGE_UNINITIALIZED;
private Function json;
Function getJson() {
if (jsonBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (jsonBuildStage == STAGE_UNINITIALIZED) {
jsonBuildStage = STAGE_INITIALIZING;
this.json = Objects.requireNonNull(ImmutableSimpleBulkOperationFactory.super.getJson(), "json");
jsonBuildStage = STAGE_INITIALIZED;
}
return this.json;
}
void json(Function json) {
this.json = json;
jsonBuildStage = STAGE_INITIALIZED;
}
private byte predicateBuildStage = STAGE_UNINITIALIZED;
private Predicate predicate;
Predicate getPredicate() {
if (predicateBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (predicateBuildStage == STAGE_UNINITIALIZED) {
predicateBuildStage = STAGE_INITIALIZING;
this.predicate = Objects.requireNonNull(ImmutableSimpleBulkOperationFactory.super.getPredicate(), "predicate");
predicateBuildStage = STAGE_INITIALIZED;
}
return this.predicate;
}
void predicate(Predicate predicate) {
this.predicate = predicate;
predicateBuildStage = STAGE_INITIALIZED;
}
private byte typeBuildStage = STAGE_UNINITIALIZED;
private Function type;
Function getType() {
if (typeBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (typeBuildStage == STAGE_UNINITIALIZED) {
typeBuildStage = STAGE_INITIALIZING;
this.type = Objects.requireNonNull(ImmutableSimpleBulkOperationFactory.super.getType(), "type");
typeBuildStage = STAGE_INITIALIZED;
}
return this.type;
}
void type(Function type) {
this.type = type;
typeBuildStage = STAGE_INITIALIZED;
}
private String formatInitCycleMessage() {
List attributes = new ArrayList<>();
if (deleteVersionBuildStage == STAGE_INITIALIZING) attributes.add("deleteVersion");
if (elasticDocumentBuildStage == STAGE_INITIALIZING) attributes.add("elasticDocument");
if (jsonBuildStage == STAGE_INITIALIZING) attributes.add("json");
if (predicateBuildStage == STAGE_INITIALIZING) attributes.add("predicate");
if (typeBuildStage == STAGE_INITIALIZING) attributes.add("type");
return "Cannot build SimpleBulkOperationFactory, attribute initializers form cycle " + attributes;
}
}
/**
* Returns the date that we should use as delete version passed to Elastic.
* @return date that we should use as delete version
*/
@Override
public Function getDeleteVersion() {
InitShim shim = this.initShim;
return shim != null
? shim.getDeleteVersion()
: this.deleteVersion;
}
/**
* @return The value of the {@code documentClass} attribute
*/
@Override
public Class getDocumentClass() {
return documentClass;
}
/**
* @return The value of the {@code elasticDocBuilder} attribute
*/
@Override
public @Nullable ElasticDocBuilder getElasticDocBuilder() {
return elasticDocBuilder;
}
/**
* @return The value of the {@code elasticDocument} attribute
*/
@Override
public Function getElasticDocument() {
InitShim shim = this.initShim;
return shim != null
? shim.getElasticDocument()
: this.elasticDocument;
}
/**
* @return The value of the {@code id} attribute
*/
@Override
public Function getId() {
return id;
}
/**
* @return The value of the {@code index} attribute
*/
@Override
public Index getIndex() {
return index;
}
/**
* @return The value of the {@code json} attribute
*/
@Override
public Function getJson() {
InitShim shim = this.initShim;
return shim != null
? shim.getJson()
: this.json;
}
/**
* @return The value of the {@code predicate} attribute
*/
@Override
public Predicate getPredicate() {
InitShim shim = this.initShim;
return shim != null
? shim.getPredicate()
: this.predicate;
}
/**
* @return The value of the {@code type} attribute
*/
@Override
public Function getType() {
InitShim shim = this.initShim;
return shim != null
? shim.getType()
: this.type;
}
/**
* Returns the date that we should use as index version passed to Elastic.
* @return date that we should use as index version
*/
@Override
public Function getVersion() {
return version;
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getDeleteVersion() deleteVersion} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for deleteVersion
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withDeleteVersion(Function value) {
if (this.deleteVersion == value) return this;
Function newValue = Objects.requireNonNull(value, "deleteVersion");
return new ImmutableSimpleBulkOperationFactory<>(
newValue,
this.documentClass,
this.elasticDocBuilder,
this.elasticDocument,
this.id,
this.index,
this.json,
this.predicate,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getDocumentClass() documentClass} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for documentClass
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withDocumentClass(Class value) {
if (this.documentClass == value) return this;
Class newValue = Objects.requireNonNull(value, "documentClass");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
newValue,
this.elasticDocBuilder,
this.elasticDocument,
this.id,
this.index,
this.json,
this.predicate,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getElasticDocBuilder() elasticDocBuilder} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for elasticDocBuilder (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withElasticDocBuilder(@Nullable ElasticDocBuilder value) {
if (this.elasticDocBuilder == value) return this;
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
value,
this.elasticDocument,
this.id,
this.index,
this.json,
this.predicate,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getElasticDocument() elasticDocument} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for elasticDocument
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withElasticDocument(Function value) {
if (this.elasticDocument == value) return this;
Function newValue = Objects.requireNonNull(value, "elasticDocument");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
this.elasticDocBuilder,
newValue,
this.id,
this.index,
this.json,
this.predicate,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getId() id} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for id
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withId(Function value) {
if (this.id == value) return this;
Function newValue = Objects.requireNonNull(value, "id");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
this.elasticDocBuilder,
this.elasticDocument,
newValue,
this.index,
this.json,
this.predicate,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getIndex() index} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for index
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withIndex(Index value) {
if (this.index == value) return this;
Index newValue = Objects.requireNonNull(value, "index");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
this.elasticDocBuilder,
this.elasticDocument,
this.id,
newValue,
this.json,
this.predicate,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getJson() json} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for json
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withJson(Function value) {
if (this.json == value) return this;
Function newValue = Objects.requireNonNull(value, "json");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
this.elasticDocBuilder,
this.elasticDocument,
this.id,
this.index,
newValue,
this.predicate,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getPredicate() predicate} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for predicate
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withPredicate(Predicate value) {
if (this.predicate == value) return this;
Predicate newValue = Objects.requireNonNull(value, "predicate");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
this.elasticDocBuilder,
this.elasticDocument,
this.id,
this.index,
this.json,
newValue,
this.type,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getType() type} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for type
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withType(Function value) {
if (this.type == value) return this;
Function newValue = Objects.requireNonNull(value, "type");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
this.elasticDocBuilder,
this.elasticDocument,
this.id,
this.index,
this.json,
this.predicate,
newValue,
this.version);
}
/**
* Copy the current immutable object by setting a value for the {@link SimpleBulkOperationFactory#getVersion() version} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for version
* @return A modified copy of the {@code this} object
*/
public final ImmutableSimpleBulkOperationFactory withVersion(Function value) {
if (this.version == value) return this;
Function newValue = Objects.requireNonNull(value, "version");
return new ImmutableSimpleBulkOperationFactory<>(
this.deleteVersion,
this.documentClass,
this.elasticDocBuilder,
this.elasticDocument,
this.id,
this.index,
this.json,
this.predicate,
this.type,
newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableSimpleBulkOperationFactory} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@javax.annotation.Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableSimpleBulkOperationFactory>
&& equalTo((ImmutableSimpleBulkOperationFactory>) another);
}
private boolean equalTo(ImmutableSimpleBulkOperationFactory> another) {
return deleteVersion.equals(another.deleteVersion)
&& documentClass.equals(another.documentClass)
&& Objects.equals(elasticDocBuilder, another.elasticDocBuilder)
&& elasticDocument.equals(another.elasticDocument)
&& id.equals(another.id)
&& index.equals(another.index)
&& json.equals(another.json)
&& predicate.equals(another.predicate)
&& type.equals(another.type)
&& version.equals(another.version);
}
/**
* Computes a hash code from attributes: {@code deleteVersion}, {@code documentClass}, {@code elasticDocBuilder}, {@code elasticDocument}, {@code id}, {@code index}, {@code json}, {@code predicate}, {@code type}, {@code version}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + deleteVersion.hashCode();
h += (h << 5) + documentClass.hashCode();
h += (h << 5) + Objects.hashCode(elasticDocBuilder);
h += (h << 5) + elasticDocument.hashCode();
h += (h << 5) + id.hashCode();
h += (h << 5) + index.hashCode();
h += (h << 5) + json.hashCode();
h += (h << 5) + predicate.hashCode();
h += (h << 5) + type.hashCode();
h += (h << 5) + version.hashCode();
return h;
}
/**
* Prints the immutable value {@code SimpleBulkOperationFactory} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("SimpleBulkOperationFactory")
.omitNullValues()
.add("deleteVersion", deleteVersion)
.add("documentClass", documentClass)
.add("elasticDocBuilder", elasticDocBuilder)
.add("elasticDocument", elasticDocument)
.add("id", id)
.add("index", index)
.add("json", json)
.add("predicate", predicate)
.add("type", type)
.add("version", version)
.toString();
}
/**
* Creates an immutable copy of a {@link SimpleBulkOperationFactory} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param generic parameter T
* @param instance The instance to copy
* @return A copied immutable SimpleBulkOperationFactory instance
*/
public static ImmutableSimpleBulkOperationFactory copyOf(SimpleBulkOperationFactory instance) {
if (instance instanceof ImmutableSimpleBulkOperationFactory>) {
return (ImmutableSimpleBulkOperationFactory) instance;
}
return ImmutableSimpleBulkOperationFactory.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableSimpleBulkOperationFactory ImmutableSimpleBulkOperationFactory}.
* @param generic parameter T
* @return A new ImmutableSimpleBulkOperationFactory builder
*/
public static ImmutableSimpleBulkOperationFactory.Builder builder() {
return new ImmutableSimpleBulkOperationFactory.Builder<>();
}
/**
* Builds instances of type {@link ImmutableSimpleBulkOperationFactory ImmutableSimpleBulkOperationFactory}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_DOCUMENT_CLASS = 0x1L;
private static final long INIT_BIT_ID = 0x2L;
private static final long INIT_BIT_INDEX = 0x4L;
private static final long INIT_BIT_VERSION = 0x8L;
private long initBits = 0xfL;
private @javax.annotation.Nullable Function deleteVersion;
private @javax.annotation.Nullable Class documentClass;
private @javax.annotation.Nullable ElasticDocBuilder elasticDocBuilder;
private @javax.annotation.Nullable Function elasticDocument;
private @javax.annotation.Nullable Function id;
private @javax.annotation.Nullable Index index;
private @javax.annotation.Nullable Function json;
private @javax.annotation.Nullable Predicate predicate;
private @javax.annotation.Nullable Function type;
private @javax.annotation.Nullable Function version;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code SimpleBulkOperationFactory} instance.
* Regular attribute values will be replaced with those from the given instance.
* Absent optional values will not replace present values.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(SimpleBulkOperationFactory instance) {
Objects.requireNonNull(instance, "instance");
deleteVersion(instance.getDeleteVersion());
documentClass(instance.getDocumentClass());
ElasticDocBuilder elasticDocBuilderValue = instance.getElasticDocBuilder();
if (elasticDocBuilderValue != null) {
elasticDocBuilder(elasticDocBuilderValue);
}
elasticDocument(instance.getElasticDocument());
id(instance.getId());
index(instance.getIndex());
json(instance.getJson());
predicate(instance.getPredicate());
type(instance.getType());
version(instance.getVersion());
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getDeleteVersion() deleteVersion} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link SimpleBulkOperationFactory#getDeleteVersion() deleteVersion}.
* @param deleteVersion The value for deleteVersion
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder deleteVersion(Function deleteVersion) {
this.deleteVersion = Objects.requireNonNull(deleteVersion, "deleteVersion");
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getDocumentClass() documentClass} attribute.
* @param documentClass The value for documentClass
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder documentClass(Class documentClass) {
this.documentClass = Objects.requireNonNull(documentClass, "documentClass");
initBits &= ~INIT_BIT_DOCUMENT_CLASS;
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getElasticDocBuilder() elasticDocBuilder} attribute.
* @param elasticDocBuilder The value for elasticDocBuilder (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder elasticDocBuilder(@Nullable ElasticDocBuilder elasticDocBuilder) {
this.elasticDocBuilder = elasticDocBuilder;
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getElasticDocument() elasticDocument} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link SimpleBulkOperationFactory#getElasticDocument() elasticDocument}.
* @param elasticDocument The value for elasticDocument
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder elasticDocument(Function elasticDocument) {
this.elasticDocument = Objects.requireNonNull(elasticDocument, "elasticDocument");
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getId() id} attribute.
* @param id The value for id
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder id(Function id) {
this.id = Objects.requireNonNull(id, "id");
initBits &= ~INIT_BIT_ID;
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getIndex() index} attribute.
* @param index The value for index
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder index(Index index) {
this.index = Objects.requireNonNull(index, "index");
initBits &= ~INIT_BIT_INDEX;
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getJson() json} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link SimpleBulkOperationFactory#getJson() json}.
* @param json The value for json
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder json(Function json) {
this.json = Objects.requireNonNull(json, "json");
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getPredicate() predicate} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link SimpleBulkOperationFactory#getPredicate() predicate}.
* @param predicate The value for predicate
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder predicate(Predicate predicate) {
this.predicate = Objects.requireNonNull(predicate, "predicate");
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getType() type} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link SimpleBulkOperationFactory#getType() type}.
* @param type The value for type
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder type(Function type) {
this.type = Objects.requireNonNull(type, "type");
return this;
}
/**
* Initializes the value for the {@link SimpleBulkOperationFactory#getVersion() version} attribute.
* @param version The value for version
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder version(Function version) {
this.version = Objects.requireNonNull(version, "version");
initBits &= ~INIT_BIT_VERSION;
return this;
}
/**
* Builds a new {@link ImmutableSimpleBulkOperationFactory ImmutableSimpleBulkOperationFactory}.
* @return An immutable instance of SimpleBulkOperationFactory
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableSimpleBulkOperationFactory build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableSimpleBulkOperationFactory(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_DOCUMENT_CLASS) != 0) attributes.add("documentClass");
if ((initBits & INIT_BIT_ID) != 0) attributes.add("id");
if ((initBits & INIT_BIT_INDEX) != 0) attributes.add("index");
if ((initBits & INIT_BIT_VERSION) != 0) attributes.add("version");
return "Cannot build SimpleBulkOperationFactory, some of required attributes are not set " + attributes;
}
}
}