com.neotys.neoload.model.repository.ImmutableVariableExtractor Maven / Gradle / Ivy
package com.neotys.neoload.model.repository;
import com.google.common.base.MoreObjects;
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 VariableExtractor}.
*
* Use the builder to create immutable instances:
* {@code ImmutableVariableExtractor.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "VariableExtractor"})
@Deprecated
@Immutable
@CheckReturnValue
public final class ImmutableVariableExtractor implements VariableExtractor {
private final String name;
private final @Nullable String startExpression;
private final @Nullable String endExpression;
private final VariableExtractor.ExtractType extractType;
private final @Nullable Integer nbOccur;
private final boolean exitOnError;
private final @Nullable String regExp;
private final @Nullable String group;
private final @Nullable String xPath;
private final @Nullable String jsonPath;
private ImmutableVariableExtractor(
String name,
@Nullable String startExpression,
@Nullable String endExpression,
VariableExtractor.ExtractType extractType,
@Nullable Integer nbOccur,
boolean exitOnError,
@Nullable String regExp,
@Nullable String group,
@Nullable String xPath,
@Nullable String jsonPath) {
this.name = name;
this.startExpression = startExpression;
this.endExpression = endExpression;
this.extractType = extractType;
this.nbOccur = nbOccur;
this.exitOnError = exitOnError;
this.regExp = regExp;
this.group = group;
this.xPath = xPath;
this.jsonPath = jsonPath;
}
/**
* @return The value of the {@code name} attribute
*/
@Override
public String getName() {
return name;
}
/**
* @return The value of the {@code startExpression} attribute
*/
@Override
public Optional getStartExpression() {
return Optional.ofNullable(startExpression);
}
/**
* @return The value of the {@code endExpression} attribute
*/
@Override
public Optional getEndExpression() {
return Optional.ofNullable(endExpression);
}
/**
* @return The value of the {@code extractType} attribute
*/
@Override
public VariableExtractor.ExtractType getExtractType() {
return extractType;
}
/**
* @return The value of the {@code nbOccur} attribute
*/
@Override
public Optional getNbOccur() {
return Optional.ofNullable(nbOccur);
}
/**
* @return The value of the {@code exitOnError} attribute
*/
@Override
public boolean getExitOnError() {
return exitOnError;
}
/**
* @return The value of the {@code regExp} attribute
*/
@Override
public Optional getRegExp() {
return Optional.ofNullable(regExp);
}
/**
* @return The value of the {@code group} attribute
*/
@Override
public Optional getGroup() {
return Optional.ofNullable(group);
}
/**
* @return The value of the {@code xPath} attribute
*/
@Override
public Optional getXPath() {
return Optional.ofNullable(xPath);
}
/**
* @return The value of the {@code jsonPath} attribute
*/
@Override
public Optional getJsonPath() {
return Optional.ofNullable(jsonPath);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#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 ImmutableVariableExtractor withName(String value) {
if (this.name.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "name");
return new ImmutableVariableExtractor(
newValue,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getStartExpression() startExpression} attribute.
* @param value The value for startExpression
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withStartExpression(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "startExpression");
if (Objects.equals(this.startExpression, newValue)) return this;
return new ImmutableVariableExtractor(
this.name,
newValue,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#getStartExpression() startExpression} 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 startExpression
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withStartExpression(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.startExpression, value)) return this;
return new ImmutableVariableExtractor(
this.name,
value,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getEndExpression() endExpression} attribute.
* @param value The value for endExpression
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withEndExpression(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "endExpression");
if (Objects.equals(this.endExpression, newValue)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
newValue,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#getEndExpression() endExpression} 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 endExpression
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withEndExpression(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.endExpression, value)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
value,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getExtractType() extractType} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for extractType
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withExtractType(VariableExtractor.ExtractType value) {
if (this.extractType == value) return this;
VariableExtractor.ExtractType newValue = Objects.requireNonNull(value, "extractType");
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
newValue,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getNbOccur() nbOccur} attribute.
* @param value The value for nbOccur
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withNbOccur(int value) {
@Nullable Integer newValue = value;
if (Objects.equals(this.nbOccur, newValue)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
newValue,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#getNbOccur() nbOccur} 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 nbOccur
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withNbOccur(Optional optional) {
@Nullable Integer value = optional.orElse(null);
if (Objects.equals(this.nbOccur, value)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
value,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getExitOnError() exitOnError} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for exitOnError
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withExitOnError(boolean value) {
if (this.exitOnError == value) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
value,
this.regExp,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getRegExp() regExp} attribute.
* @param value The value for regExp
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withRegExp(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "regExp");
if (Objects.equals(this.regExp, newValue)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
newValue,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#getRegExp() regExp} 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 regExp
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withRegExp(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.regExp, value)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
value,
this.group,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getGroup() group} attribute.
* @param value The value for group
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withGroup(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "group");
if (Objects.equals(this.group, newValue)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
newValue,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#getGroup() group} 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 group
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withGroup(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.group, value)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
value,
this.xPath,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getXPath() xPath} attribute.
* @param value The value for xPath
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withXPath(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "xPath");
if (Objects.equals(this.xPath, newValue)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
newValue,
this.jsonPath);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#getXPath() xPath} 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 xPath
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withXPath(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.xPath, value)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
value,
this.jsonPath);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getJsonPath() jsonPath} attribute.
* @param value The value for jsonPath
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withJsonPath(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "jsonPath");
if (Objects.equals(this.jsonPath, newValue)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#getJsonPath() jsonPath} 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 jsonPath
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withJsonPath(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.jsonPath, value)) return this;
return new ImmutableVariableExtractor(
this.name,
this.startExpression,
this.endExpression,
this.extractType,
this.nbOccur,
this.exitOnError,
this.regExp,
this.group,
this.xPath,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableVariableExtractor} 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 ImmutableVariableExtractor
&& equalTo((ImmutableVariableExtractor) another);
}
private boolean equalTo(ImmutableVariableExtractor another) {
return name.equals(another.name)
&& Objects.equals(startExpression, another.startExpression)
&& Objects.equals(endExpression, another.endExpression)
&& extractType.equals(another.extractType)
&& Objects.equals(nbOccur, another.nbOccur)
&& exitOnError == another.exitOnError
&& Objects.equals(regExp, another.regExp)
&& Objects.equals(group, another.group)
&& Objects.equals(xPath, another.xPath)
&& Objects.equals(jsonPath, another.jsonPath);
}
/**
* Computes a hash code from attributes: {@code name}, {@code startExpression}, {@code endExpression}, {@code extractType}, {@code nbOccur}, {@code exitOnError}, {@code regExp}, {@code group}, {@code xPath}, {@code jsonPath}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + name.hashCode();
h += (h << 5) + Objects.hashCode(startExpression);
h += (h << 5) + Objects.hashCode(endExpression);
h += (h << 5) + extractType.hashCode();
h += (h << 5) + Objects.hashCode(nbOccur);
h += (h << 5) + Booleans.hashCode(exitOnError);
h += (h << 5) + Objects.hashCode(regExp);
h += (h << 5) + Objects.hashCode(group);
h += (h << 5) + Objects.hashCode(xPath);
h += (h << 5) + Objects.hashCode(jsonPath);
return h;
}
/**
* Prints the immutable value {@code VariableExtractor} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("VariableExtractor")
.omitNullValues()
.add("name", name)
.add("startExpression", startExpression)
.add("endExpression", endExpression)
.add("extractType", extractType)
.add("nbOccur", nbOccur)
.add("exitOnError", exitOnError)
.add("regExp", regExp)
.add("group", group)
.add("xPath", xPath)
.add("jsonPath", jsonPath)
.toString();
}
/**
* Creates an immutable copy of a {@link VariableExtractor} 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 VariableExtractor instance
*/
public static ImmutableVariableExtractor copyOf(VariableExtractor instance) {
if (instance instanceof ImmutableVariableExtractor) {
return (ImmutableVariableExtractor) instance;
}
return ImmutableVariableExtractor.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableVariableExtractor ImmutableVariableExtractor}.
* @return A new ImmutableVariableExtractor builder
*/
public static ImmutableVariableExtractor.Builder builder() {
return new ImmutableVariableExtractor.Builder();
}
/**
* Builds instances of type {@link ImmutableVariableExtractor ImmutableVariableExtractor}.
* 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_NAME = 0x1L;
private static final long INIT_BIT_EXTRACT_TYPE = 0x2L;
private static final long INIT_BIT_EXIT_ON_ERROR = 0x4L;
private long initBits = 0x7L;
private @Nullable String name;
private @Nullable String startExpression;
private @Nullable String endExpression;
private @Nullable VariableExtractor.ExtractType extractType;
private @Nullable Integer nbOccur;
private boolean exitOnError;
private @Nullable String regExp;
private @Nullable String group;
private @Nullable String xPath;
private @Nullable String jsonPath;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code VariableExtractor} 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(VariableExtractor instance) {
Objects.requireNonNull(instance, "instance");
name(instance.getName());
Optional startExpressionOptional = instance.getStartExpression();
if (startExpressionOptional.isPresent()) {
startExpression(startExpressionOptional);
}
Optional endExpressionOptional = instance.getEndExpression();
if (endExpressionOptional.isPresent()) {
endExpression(endExpressionOptional);
}
extractType(instance.getExtractType());
Optional nbOccurOptional = instance.getNbOccur();
if (nbOccurOptional.isPresent()) {
nbOccur(nbOccurOptional);
}
exitOnError(instance.getExitOnError());
Optional regExpOptional = instance.getRegExp();
if (regExpOptional.isPresent()) {
regExp(regExpOptional);
}
Optional groupOptional = instance.getGroup();
if (groupOptional.isPresent()) {
group(groupOptional);
}
Optional xPathOptional = instance.getXPath();
if (xPathOptional.isPresent()) {
xPath(xPathOptional);
}
Optional jsonPathOptional = instance.getJsonPath();
if (jsonPathOptional.isPresent()) {
jsonPath(jsonPathOptional);
}
return this;
}
/**
* Initializes the value for the {@link VariableExtractor#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 VariableExtractor#getStartExpression() startExpression} to startExpression.
* @param startExpression The value for startExpression
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder startExpression(String startExpression) {
this.startExpression = Objects.requireNonNull(startExpression, "startExpression");
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getStartExpression() startExpression} to startExpression.
* @param startExpression The value for startExpression
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder startExpression(Optional startExpression) {
this.startExpression = startExpression.orElse(null);
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getEndExpression() endExpression} to endExpression.
* @param endExpression The value for endExpression
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder endExpression(String endExpression) {
this.endExpression = Objects.requireNonNull(endExpression, "endExpression");
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getEndExpression() endExpression} to endExpression.
* @param endExpression The value for endExpression
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder endExpression(Optional endExpression) {
this.endExpression = endExpression.orElse(null);
return this;
}
/**
* Initializes the value for the {@link VariableExtractor#getExtractType() extractType} attribute.
* @param extractType The value for extractType
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder extractType(VariableExtractor.ExtractType extractType) {
this.extractType = Objects.requireNonNull(extractType, "extractType");
initBits &= ~INIT_BIT_EXTRACT_TYPE;
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getNbOccur() nbOccur} to nbOccur.
* @param nbOccur The value for nbOccur
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder nbOccur(int nbOccur) {
this.nbOccur = nbOccur;
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getNbOccur() nbOccur} to nbOccur.
* @param nbOccur The value for nbOccur
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder nbOccur(Optional nbOccur) {
this.nbOccur = nbOccur.orElse(null);
return this;
}
/**
* Initializes the value for the {@link VariableExtractor#getExitOnError() exitOnError} attribute.
* @param exitOnError The value for exitOnError
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder exitOnError(boolean exitOnError) {
this.exitOnError = exitOnError;
initBits &= ~INIT_BIT_EXIT_ON_ERROR;
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getRegExp() regExp} to regExp.
* @param regExp The value for regExp
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder regExp(String regExp) {
this.regExp = Objects.requireNonNull(regExp, "regExp");
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getRegExp() regExp} to regExp.
* @param regExp The value for regExp
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder regExp(Optional regExp) {
this.regExp = regExp.orElse(null);
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getGroup() group} to group.
* @param group The value for group
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder group(String group) {
this.group = Objects.requireNonNull(group, "group");
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getGroup() group} to group.
* @param group The value for group
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder group(Optional group) {
this.group = group.orElse(null);
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getXPath() xPath} to xPath.
* @param xPath The value for xPath
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder xPath(String xPath) {
this.xPath = Objects.requireNonNull(xPath, "xPath");
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getXPath() xPath} to xPath.
* @param xPath The value for xPath
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder xPath(Optional xPath) {
this.xPath = xPath.orElse(null);
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getJsonPath() jsonPath} to jsonPath.
* @param jsonPath The value for jsonPath
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder jsonPath(String jsonPath) {
this.jsonPath = Objects.requireNonNull(jsonPath, "jsonPath");
return this;
}
/**
* Initializes the optional value {@link VariableExtractor#getJsonPath() jsonPath} to jsonPath.
* @param jsonPath The value for jsonPath
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder jsonPath(Optional jsonPath) {
this.jsonPath = jsonPath.orElse(null);
return this;
}
/**
* Builds a new {@link ImmutableVariableExtractor ImmutableVariableExtractor}.
* @return An immutable instance of VariableExtractor
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableVariableExtractor build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableVariableExtractor(
name,
startExpression,
endExpression,
extractType,
nbOccur,
exitOnError,
regExp,
group,
xPath,
jsonPath);
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
if ((initBits & INIT_BIT_EXTRACT_TYPE) != 0) attributes.add("extractType");
if ((initBits & INIT_BIT_EXIT_ON_ERROR) != 0) attributes.add("exitOnError");
return "Cannot build VariableExtractor, some of required attributes are not set " + attributes;
}
}
}