com.neotys.neoload.model.repository.ImmutableFileVariable Maven / Gradle / Ivy
package com.neotys.neoload.model.repository;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link FileVariable}.
*
* Use the builder to create immutable instances:
* {@code ImmutableFileVariable.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "FileVariable"})
@Deprecated
@Immutable
@CheckReturnValue
public final class ImmutableFileVariable implements FileVariable {
private final String columnsDelimiter;
private final ImmutableList columnsNames;
private final @Nullable String[][] data;
private final @Nullable String fileName;
private final boolean firstLineIsColumnName;
private final int numOfFirstRowData;
private final String name;
private final @Nullable String description;
private final @Nullable Variable.VariableOrder order;
private final Variable.VariablePolicy policy;
private final Variable.VariableScope scope;
private final @Nullable Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior;
private ImmutableFileVariable(
String columnsDelimiter,
ImmutableList columnsNames,
@Nullable String[][] data,
@Nullable String fileName,
boolean firstLineIsColumnName,
int numOfFirstRowData,
String name,
@Nullable String description,
@Nullable Variable.VariableOrder order,
Variable.VariablePolicy policy,
Variable.VariableScope scope,
@Nullable Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior) {
this.columnsDelimiter = columnsDelimiter;
this.columnsNames = columnsNames;
this.data = data;
this.fileName = fileName;
this.firstLineIsColumnName = firstLineIsColumnName;
this.numOfFirstRowData = numOfFirstRowData;
this.name = name;
this.description = description;
this.order = order;
this.policy = policy;
this.scope = scope;
this.noValuesLeftBehavior = noValuesLeftBehavior;
}
/**
* @return The value of the {@code columnsDelimiter} attribute
*/
@Override
public String getColumnsDelimiter() {
return columnsDelimiter;
}
/**
* @return The value of the {@code columnsNames} attribute
*/
@Override
public ImmutableList getColumnsNames() {
return columnsNames;
}
/**
* @return The value of the {@code data} attribute
*/
@Override
public Optional getData() {
return Optional.ofNullable(data);
}
/**
* @return The value of the {@code fileName} attribute
*/
@Override
public Optional getFileName() {
return Optional.ofNullable(fileName);
}
/**
* @return The value of the {@code firstLineIsColumnName} attribute
*/
@Override
public boolean getFirstLineIsColumnName() {
return firstLineIsColumnName;
}
/**
* @return The value of the {@code numOfFirstRowData} attribute
*/
@Override
public int getNumOfFirstRowData() {
return numOfFirstRowData;
}
/**
* @return The value of the {@code name} attribute
*/
@Override
public String getName() {
return name;
}
/**
* @return The value of the {@code description} attribute
*/
@Override
public Optional getDescription() {
return Optional.ofNullable(description);
}
/**
* @return The value of the {@code order} attribute
*/
@Override
public Optional getOrder() {
return Optional.ofNullable(order);
}
/**
* @return The value of the {@code policy} attribute
*/
@Override
public Variable.VariablePolicy getPolicy() {
return policy;
}
/**
* @return The value of the {@code scope} attribute
*/
@Override
public Variable.VariableScope getScope() {
return scope;
}
/**
* @return The value of the {@code noValuesLeftBehavior} attribute
*/
@Override
public Optional getNoValuesLeftBehavior() {
return Optional.ofNullable(noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a value for the {@link FileVariable#getColumnsDelimiter() columnsDelimiter} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for columnsDelimiter
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileVariable withColumnsDelimiter(String value) {
if (this.columnsDelimiter.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "columnsDelimiter");
return new ImmutableFileVariable(
newValue,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object with elements that replace the content of {@link FileVariable#getColumnsNames() columnsNames}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withColumnsNames(String... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableFileVariable(
this.columnsDelimiter,
newValue,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object with elements that replace the content of {@link FileVariable#getColumnsNames() columnsNames}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of columnsNames elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withColumnsNames(Iterable elements) {
if (this.columnsNames == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return new ImmutableFileVariable(
this.columnsDelimiter,
newValue,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link FileVariable#getData() data} attribute.
* @param value The value for data
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withData(String[][] value) {
@Nullable String[][] newValue = Objects.requireNonNull(value, "data");
if (this.data == newValue) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
newValue,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting an optional value for the {@link FileVariable#getData() data} attribute.
* A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}.
* @param optional A value for data
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withData(Optional extends String[][]> optional) {
@Nullable String[][] value = optional.orElse(null);
if (this.data == value) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
value,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link FileVariable#getFileName() fileName} attribute.
* @param value The value for fileName
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withFileName(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "fileName");
if (Objects.equals(this.fileName, newValue)) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
newValue,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting an optional value for the {@link FileVariable#getFileName() fileName} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for fileName
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withFileName(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.fileName, value)) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
value,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a value for the {@link FileVariable#getFirstLineIsColumnName() firstLineIsColumnName} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for firstLineIsColumnName
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileVariable withFirstLineIsColumnName(boolean value) {
if (this.firstLineIsColumnName == value) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
value,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a value for the {@link FileVariable#getNumOfFirstRowData() numOfFirstRowData} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for numOfFirstRowData
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileVariable withNumOfFirstRowData(int value) {
if (this.numOfFirstRowData == value) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
value,
this.name,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a value for the {@link FileVariable#getName() name} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for name
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileVariable withName(String value) {
if (this.name.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "name");
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
newValue,
this.description,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link FileVariable#getDescription() description} attribute.
* @param value The value for description
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withDescription(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "description");
if (Objects.equals(this.description, newValue)) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
newValue,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting an optional value for the {@link FileVariable#getDescription() description} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for description
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
value,
this.order,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link FileVariable#getOrder() order} attribute.
* @param value The value for order
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withOrder(Variable.VariableOrder value) {
@Nullable Variable.VariableOrder newValue = Objects.requireNonNull(value, "order");
if (this.order == newValue) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
newValue,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting an optional value for the {@link FileVariable#getOrder() order} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for order
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withOrder(Optional extends Variable.VariableOrder> optional) {
@Nullable Variable.VariableOrder value = optional.orElse(null);
if (Objects.equals(this.order, value)) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
value,
this.policy,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a value for the {@link FileVariable#getPolicy() policy} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for policy
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileVariable withPolicy(Variable.VariablePolicy value) {
if (this.policy == value) return this;
Variable.VariablePolicy newValue = Objects.requireNonNull(value, "policy");
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
newValue,
this.scope,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a value for the {@link FileVariable#getScope() scope} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for scope
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileVariable withScope(Variable.VariableScope value) {
if (this.scope == value) return this;
Variable.VariableScope newValue = Objects.requireNonNull(value, "scope");
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
newValue,
this.noValuesLeftBehavior);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link FileVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} attribute.
* @param value The value for noValuesLeftBehavior
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withNoValuesLeftBehavior(Variable.VariableNoValuesLeftBehavior value) {
@Nullable Variable.VariableNoValuesLeftBehavior newValue = Objects.requireNonNull(value, "noValuesLeftBehavior");
if (this.noValuesLeftBehavior == newValue) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link FileVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for noValuesLeftBehavior
* @return A modified copy of {@code this} object
*/
public final ImmutableFileVariable withNoValuesLeftBehavior(Optional extends Variable.VariableNoValuesLeftBehavior> optional) {
@Nullable Variable.VariableNoValuesLeftBehavior value = optional.orElse(null);
if (Objects.equals(this.noValuesLeftBehavior, value)) return this;
return new ImmutableFileVariable(
this.columnsDelimiter,
this.columnsNames,
this.data,
this.fileName,
this.firstLineIsColumnName,
this.numOfFirstRowData,
this.name,
this.description,
this.order,
this.policy,
this.scope,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableFileVariable} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableFileVariable
&& equalTo((ImmutableFileVariable) another);
}
private boolean equalTo(ImmutableFileVariable another) {
return columnsDelimiter.equals(another.columnsDelimiter)
&& columnsNames.equals(another.columnsNames)
&& Objects.equals(data, another.data)
&& Objects.equals(fileName, another.fileName)
&& firstLineIsColumnName == another.firstLineIsColumnName
&& numOfFirstRowData == another.numOfFirstRowData
&& name.equals(another.name)
&& Objects.equals(description, another.description)
&& Objects.equals(order, another.order)
&& policy.equals(another.policy)
&& scope.equals(another.scope)
&& Objects.equals(noValuesLeftBehavior, another.noValuesLeftBehavior);
}
/**
* Computes a hash code from attributes: {@code columnsDelimiter}, {@code columnsNames}, {@code data}, {@code fileName}, {@code firstLineIsColumnName}, {@code numOfFirstRowData}, {@code name}, {@code description}, {@code order}, {@code policy}, {@code scope}, {@code noValuesLeftBehavior}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + columnsDelimiter.hashCode();
h += (h << 5) + columnsNames.hashCode();
h += (h << 5) + Objects.hashCode(data);
h += (h << 5) + Objects.hashCode(fileName);
h += (h << 5) + Booleans.hashCode(firstLineIsColumnName);
h += (h << 5) + numOfFirstRowData;
h += (h << 5) + name.hashCode();
h += (h << 5) + Objects.hashCode(description);
h += (h << 5) + Objects.hashCode(order);
h += (h << 5) + policy.hashCode();
h += (h << 5) + scope.hashCode();
h += (h << 5) + Objects.hashCode(noValuesLeftBehavior);
return h;
}
/**
* Prints the immutable value {@code FileVariable} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("FileVariable")
.omitNullValues()
.add("columnsDelimiter", columnsDelimiter)
.add("columnsNames", columnsNames)
.add("data", data)
.add("fileName", fileName)
.add("firstLineIsColumnName", firstLineIsColumnName)
.add("numOfFirstRowData", numOfFirstRowData)
.add("name", name)
.add("description", description)
.add("order", order)
.add("policy", policy)
.add("scope", scope)
.add("noValuesLeftBehavior", noValuesLeftBehavior)
.toString();
}
/**
* Creates an immutable copy of a {@link FileVariable} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance The instance to copy
* @return A copied immutable FileVariable instance
*/
public static ImmutableFileVariable copyOf(FileVariable instance) {
if (instance instanceof ImmutableFileVariable) {
return (ImmutableFileVariable) instance;
}
return ImmutableFileVariable.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableFileVariable ImmutableFileVariable}.
* @return A new ImmutableFileVariable builder
*/
public static ImmutableFileVariable.Builder builder() {
return new ImmutableFileVariable.Builder();
}
/**
* Builds instances of type {@link ImmutableFileVariable ImmutableFileVariable}.
* 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_COLUMNS_DELIMITER = 0x1L;
private static final long INIT_BIT_FIRST_LINE_IS_COLUMN_NAME = 0x2L;
private static final long INIT_BIT_NUM_OF_FIRST_ROW_DATA = 0x4L;
private static final long INIT_BIT_NAME = 0x8L;
private static final long INIT_BIT_POLICY = 0x10L;
private static final long INIT_BIT_SCOPE = 0x20L;
private long initBits = 0x3fL;
private @Nullable String columnsDelimiter;
private ImmutableList.Builder columnsNames = ImmutableList.builder();
private @Nullable String[][] data;
private @Nullable String fileName;
private boolean firstLineIsColumnName;
private int numOfFirstRowData;
private @Nullable String name;
private @Nullable String description;
private @Nullable Variable.VariableOrder order;
private @Nullable Variable.VariablePolicy policy;
private @Nullable Variable.VariableScope scope;
private @Nullable Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.repository.Variable} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(Variable instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.repository.FileVariable} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(FileVariable instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
private void from(Object object) {
if (object instanceof Variable) {
Variable instance = (Variable) object;
name(instance.getName());
Optional noValuesLeftBehaviorOptional = instance.getNoValuesLeftBehavior();
if (noValuesLeftBehaviorOptional.isPresent()) {
noValuesLeftBehavior(noValuesLeftBehaviorOptional);
}
Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
description(descriptionOptional);
}
scope(instance.getScope());
Optional orderOptional = instance.getOrder();
if (orderOptional.isPresent()) {
order(orderOptional);
}
policy(instance.getPolicy());
}
if (object instanceof FileVariable) {
FileVariable instance = (FileVariable) object;
addAllColumnsNames(instance.getColumnsNames());
columnsDelimiter(instance.getColumnsDelimiter());
Optional fileNameOptional = instance.getFileName();
if (fileNameOptional.isPresent()) {
fileName(fileNameOptional);
}
numOfFirstRowData(instance.getNumOfFirstRowData());
Optional dataOptional = instance.getData();
if (dataOptional.isPresent()) {
data(dataOptional);
}
firstLineIsColumnName(instance.getFirstLineIsColumnName());
}
}
/**
* Initializes the value for the {@link FileVariable#getColumnsDelimiter() columnsDelimiter} attribute.
* @param columnsDelimiter The value for columnsDelimiter
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder columnsDelimiter(String columnsDelimiter) {
this.columnsDelimiter = Objects.requireNonNull(columnsDelimiter, "columnsDelimiter");
initBits &= ~INIT_BIT_COLUMNS_DELIMITER;
return this;
}
/**
* Adds one element to {@link FileVariable#getColumnsNames() columnsNames} list.
* @param element A columnsNames element
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addColumnsNames(String element) {
this.columnsNames.add(element);
return this;
}
/**
* Adds elements to {@link FileVariable#getColumnsNames() columnsNames} list.
* @param elements An array of columnsNames elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addColumnsNames(String... elements) {
this.columnsNames.add(elements);
return this;
}
/**
* Sets or replaces all elements for {@link FileVariable#getColumnsNames() columnsNames} list.
* @param elements An iterable of columnsNames elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder columnsNames(Iterable elements) {
this.columnsNames = ImmutableList.builder();
return addAllColumnsNames(elements);
}
/**
* Adds elements to {@link FileVariable#getColumnsNames() columnsNames} list.
* @param elements An iterable of columnsNames elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addAllColumnsNames(Iterable elements) {
this.columnsNames.addAll(elements);
return this;
}
/**
* Initializes the optional value {@link FileVariable#getData() data} to data.
* @param data The value for data
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder data(String[][] data) {
this.data = Objects.requireNonNull(data, "data");
return this;
}
/**
* Initializes the optional value {@link FileVariable#getData() data} to data.
* @param data The value for data
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder data(Optional extends String[][]> data) {
this.data = data.orElse(null);
return this;
}
/**
* Initializes the optional value {@link FileVariable#getFileName() fileName} to fileName.
* @param fileName The value for fileName
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder fileName(String fileName) {
this.fileName = Objects.requireNonNull(fileName, "fileName");
return this;
}
/**
* Initializes the optional value {@link FileVariable#getFileName() fileName} to fileName.
* @param fileName The value for fileName
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder fileName(Optional fileName) {
this.fileName = fileName.orElse(null);
return this;
}
/**
* Initializes the value for the {@link FileVariable#getFirstLineIsColumnName() firstLineIsColumnName} attribute.
* @param firstLineIsColumnName The value for firstLineIsColumnName
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder firstLineIsColumnName(boolean firstLineIsColumnName) {
this.firstLineIsColumnName = firstLineIsColumnName;
initBits &= ~INIT_BIT_FIRST_LINE_IS_COLUMN_NAME;
return this;
}
/**
* Initializes the value for the {@link FileVariable#getNumOfFirstRowData() numOfFirstRowData} attribute.
* @param numOfFirstRowData The value for numOfFirstRowData
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder numOfFirstRowData(int numOfFirstRowData) {
this.numOfFirstRowData = numOfFirstRowData;
initBits &= ~INIT_BIT_NUM_OF_FIRST_ROW_DATA;
return this;
}
/**
* Initializes the value for the {@link FileVariable#getName() name} attribute.
* @param name The value for name
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder name(String name) {
this.name = Objects.requireNonNull(name, "name");
initBits &= ~INIT_BIT_NAME;
return this;
}
/**
* Initializes the optional value {@link FileVariable#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder description(String description) {
this.description = Objects.requireNonNull(description, "description");
return this;
}
/**
* Initializes the optional value {@link FileVariable#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder description(Optional description) {
this.description = description.orElse(null);
return this;
}
/**
* Initializes the optional value {@link FileVariable#getOrder() order} to order.
* @param order The value for order
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder order(Variable.VariableOrder order) {
this.order = Objects.requireNonNull(order, "order");
return this;
}
/**
* Initializes the optional value {@link FileVariable#getOrder() order} to order.
* @param order The value for order
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder order(Optional extends Variable.VariableOrder> order) {
this.order = order.orElse(null);
return this;
}
/**
* Initializes the value for the {@link FileVariable#getPolicy() policy} attribute.
* @param policy The value for policy
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder policy(Variable.VariablePolicy policy) {
this.policy = Objects.requireNonNull(policy, "policy");
initBits &= ~INIT_BIT_POLICY;
return this;
}
/**
* Initializes the value for the {@link FileVariable#getScope() scope} attribute.
* @param scope The value for scope
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder scope(Variable.VariableScope scope) {
this.scope = Objects.requireNonNull(scope, "scope");
initBits &= ~INIT_BIT_SCOPE;
return this;
}
/**
* Initializes the optional value {@link FileVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} to noValuesLeftBehavior.
* @param noValuesLeftBehavior The value for noValuesLeftBehavior
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder noValuesLeftBehavior(Variable.VariableNoValuesLeftBehavior noValuesLeftBehavior) {
this.noValuesLeftBehavior = Objects.requireNonNull(noValuesLeftBehavior, "noValuesLeftBehavior");
return this;
}
/**
* Initializes the optional value {@link FileVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} to noValuesLeftBehavior.
* @param noValuesLeftBehavior The value for noValuesLeftBehavior
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder noValuesLeftBehavior(Optional extends Variable.VariableNoValuesLeftBehavior> noValuesLeftBehavior) {
this.noValuesLeftBehavior = noValuesLeftBehavior.orElse(null);
return this;
}
/**
* Builds a new {@link ImmutableFileVariable ImmutableFileVariable}.
* @return An immutable instance of FileVariable
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableFileVariable build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableFileVariable(
columnsDelimiter,
columnsNames.build(),
data,
fileName,
firstLineIsColumnName,
numOfFirstRowData,
name,
description,
order,
policy,
scope,
noValuesLeftBehavior);
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_COLUMNS_DELIMITER) != 0) attributes.add("columnsDelimiter");
if ((initBits & INIT_BIT_FIRST_LINE_IS_COLUMN_NAME) != 0) attributes.add("firstLineIsColumnName");
if ((initBits & INIT_BIT_NUM_OF_FIRST_ROW_DATA) != 0) attributes.add("numOfFirstRowData");
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
if ((initBits & INIT_BIT_POLICY) != 0) attributes.add("policy");
if ((initBits & INIT_BIT_SCOPE) != 0) attributes.add("scope");
return "Cannot build FileVariable, some of required attributes are not set " + attributes;
}
}
}