com.neotys.neoload.model.v3.project.userpath.ImmutableVariableExtractor Maven / Gradle / Ivy
package com.neotys.neoload.model.v3.project.userpath;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
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 com.neotys.neoload.model.v3.project.Element;
import com.neotys.neoload.model.v3.validation.groups.NeoLoad;
import java.util.ArrayList;
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;
import javax.validation.constraints.Min;
/**
* Immutable implementation of {@link VariableExtractor}.
*
* Use the builder to create immutable instances:
* {@code new VariableExtractor.Builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "VariableExtractor"})
@Immutable
@CheckReturnValue
public final class ImmutableVariableExtractor
implements VariableExtractor {
private final VariableExtractor.From from;
private final @Nullable String xpath;
private final @Nullable String jsonPath;
private final String regexp;
private final @Min(value = -1, groups = {NeoLoad.class}) int matchNumber;
private final String template;
private final Optional decode;
private final boolean extractOnce;
private final String getDefault;
private final boolean throwAssertionError;
private final String name;
private final @Nullable String description;
private ImmutableVariableExtractor(ImmutableVariableExtractor.Builder builder) {
this.xpath = builder.xpath;
this.jsonPath = builder.jsonPath;
this.name = builder.name;
this.description = builder.description;
if (builder.from != null) {
initShim.from(builder.from);
}
if (builder.regexp != null) {
initShim.regexp(builder.regexp);
}
if (builder.matchNumberIsSet()) {
initShim.matchNumber(builder.matchNumber);
}
if (builder.template != null) {
initShim.template(builder.template);
}
if (builder.decode != null) {
initShim.decode(builder.decode);
}
if (builder.extractOnceIsSet()) {
initShim.extractOnce(builder.extractOnce);
}
if (builder.getDefault != null) {
initShim.getDefault(builder.getDefault);
}
if (builder.throwAssertionErrorIsSet()) {
initShim.throwAssertionError(builder.throwAssertionError);
}
this.from = initShim.getFrom();
this.regexp = initShim.getRegexp();
this.matchNumber = initShim.getMatchNumber();
this.template = initShim.getTemplate();
this.decode = initShim.getDecode();
this.extractOnce = initShim.getExtractOnce();
this.getDefault = initShim.getDefault();
this.throwAssertionError = initShim.getThrowAssertionError();
this.initShim = null;
}
private ImmutableVariableExtractor(
VariableExtractor.From from,
@Nullable String xpath,
@Nullable String jsonPath,
String regexp,
@Min(value = -1, groups = {NeoLoad.class}) int matchNumber,
String template,
Optional decode,
boolean extractOnce,
String getDefault,
boolean throwAssertionError,
String name,
@Nullable String description) {
this.from = from;
this.xpath = xpath;
this.jsonPath = jsonPath;
this.regexp = regexp;
this.matchNumber = matchNumber;
this.template = template;
this.decode = decode;
this.extractOnce = extractOnce;
this.getDefault = getDefault;
this.throwAssertionError = throwAssertionError;
this.name = name;
this.description = description;
this.initShim = null;
}
private static final int STAGE_INITIALIZING = -1;
private static final int STAGE_UNINITIALIZED = 0;
private static final int STAGE_INITIALIZED = 1;
private transient volatile InitShim initShim = new InitShim();
private final class InitShim {
private VariableExtractor.From from;
private int fromBuildStage;
VariableExtractor.From getFrom() {
if (fromBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (fromBuildStage == STAGE_UNINITIALIZED) {
fromBuildStage = STAGE_INITIALIZING;
this.from = Objects.requireNonNull(getFromInitialize(), "from");
fromBuildStage = STAGE_INITIALIZED;
}
return this.from;
}
void from(VariableExtractor.From from) {
this.from = from;
fromBuildStage = STAGE_INITIALIZED;
}
private String regexp;
private int regexpBuildStage;
String getRegexp() {
if (regexpBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (regexpBuildStage == STAGE_UNINITIALIZED) {
regexpBuildStage = STAGE_INITIALIZING;
this.regexp = Objects.requireNonNull(getRegexpInitialize(), "regexp");
regexpBuildStage = STAGE_INITIALIZED;
}
return this.regexp;
}
void regexp(String regexp) {
this.regexp = regexp;
regexpBuildStage = STAGE_INITIALIZED;
}
private @Min(value = -1, groups = {NeoLoad.class}) int matchNumber;
private int matchNumberBuildStage;
@Min(value = -1, groups = {NeoLoad.class}) int getMatchNumber() {
if (matchNumberBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (matchNumberBuildStage == STAGE_UNINITIALIZED) {
matchNumberBuildStage = STAGE_INITIALIZING;
this.matchNumber = getMatchNumberInitialize();
matchNumberBuildStage = STAGE_INITIALIZED;
}
return this.matchNumber;
}
void matchNumber(@Min(value = -1, groups = {NeoLoad.class}) int matchNumber) {
this.matchNumber = matchNumber;
matchNumberBuildStage = STAGE_INITIALIZED;
}
private String template;
private int templateBuildStage;
String getTemplate() {
if (templateBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (templateBuildStage == STAGE_UNINITIALIZED) {
templateBuildStage = STAGE_INITIALIZING;
this.template = Objects.requireNonNull(getTemplateInitialize(), "template");
templateBuildStage = STAGE_INITIALIZED;
}
return this.template;
}
void template(String template) {
this.template = template;
templateBuildStage = STAGE_INITIALIZED;
}
private Optional decode;
private int decodeBuildStage;
Optional getDecode() {
if (decodeBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (decodeBuildStage == STAGE_UNINITIALIZED) {
decodeBuildStage = STAGE_INITIALIZING;
this.decode = Objects.requireNonNull(getDecodeInitialize(), "decode");
decodeBuildStage = STAGE_INITIALIZED;
}
return this.decode;
}
void decode(Optional decode) {
this.decode = decode;
decodeBuildStage = STAGE_INITIALIZED;
}
private boolean extractOnce;
private int extractOnceBuildStage;
boolean getExtractOnce() {
if (extractOnceBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (extractOnceBuildStage == STAGE_UNINITIALIZED) {
extractOnceBuildStage = STAGE_INITIALIZING;
this.extractOnce = getExtractOnceInitialize();
extractOnceBuildStage = STAGE_INITIALIZED;
}
return this.extractOnce;
}
void extractOnce(boolean extractOnce) {
this.extractOnce = extractOnce;
extractOnceBuildStage = STAGE_INITIALIZED;
}
private String getDefault;
private int getDefaultBuildStage;
String getDefault() {
if (getDefaultBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (getDefaultBuildStage == STAGE_UNINITIALIZED) {
getDefaultBuildStage = STAGE_INITIALIZING;
this.getDefault = Objects.requireNonNull(getDefaultInitialize(), "getDefault");
getDefaultBuildStage = STAGE_INITIALIZED;
}
return this.getDefault;
}
void getDefault(String getDefault) {
this.getDefault = getDefault;
getDefaultBuildStage = STAGE_INITIALIZED;
}
private boolean throwAssertionError;
private int throwAssertionErrorBuildStage;
boolean getThrowAssertionError() {
if (throwAssertionErrorBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (throwAssertionErrorBuildStage == STAGE_UNINITIALIZED) {
throwAssertionErrorBuildStage = STAGE_INITIALIZING;
this.throwAssertionError = getThrowAssertionErrorInitialize();
throwAssertionErrorBuildStage = STAGE_INITIALIZED;
}
return this.throwAssertionError;
}
void throwAssertionError(boolean throwAssertionError) {
this.throwAssertionError = throwAssertionError;
throwAssertionErrorBuildStage = STAGE_INITIALIZED;
}
private String formatInitCycleMessage() {
ArrayList attributes = Lists.newArrayList();
if (fromBuildStage == STAGE_INITIALIZING) attributes.add("from");
if (regexpBuildStage == STAGE_INITIALIZING) attributes.add("regexp");
if (matchNumberBuildStage == STAGE_INITIALIZING) attributes.add("matchNumber");
if (templateBuildStage == STAGE_INITIALIZING) attributes.add("template");
if (decodeBuildStage == STAGE_INITIALIZING) attributes.add("decode");
if (extractOnceBuildStage == STAGE_INITIALIZING) attributes.add("extractOnce");
if (getDefaultBuildStage == STAGE_INITIALIZING) attributes.add("getDefault");
if (throwAssertionErrorBuildStage == STAGE_INITIALIZING) attributes.add("throwAssertionError");
return "Cannot build VariableExtractor, attribute initializers form cycle" + attributes;
}
}
private VariableExtractor.From getFromInitialize() {
return VariableExtractor.super.getFrom();
}
private String getRegexpInitialize() {
return VariableExtractor.super.getRegexp();
}
private @Min(value = -1, groups = {NeoLoad.class}) int getMatchNumberInitialize() {
return VariableExtractor.super.getMatchNumber();
}
private String getTemplateInitialize() {
return VariableExtractor.super.getTemplate();
}
private Optional getDecodeInitialize() {
return VariableExtractor.super.getDecode();
}
private boolean getExtractOnceInitialize() {
return VariableExtractor.super.getExtractOnce();
}
private String getDefaultInitialize() {
return VariableExtractor.super.getDefault();
}
private boolean getThrowAssertionErrorInitialize() {
return VariableExtractor.super.getThrowAssertionError();
}
/**
* @return The value of the {@code from} attribute
*/
@JsonProperty("from")
@Override
public VariableExtractor.From getFrom() {
InitShim shim = this.initShim;
return shim != null
? shim.getFrom()
: this.from;
}
/**
* @return The value of the {@code xpath} attribute
*/
@JsonProperty("xpath")
@Override
public Optional getXpath() {
return Optional.ofNullable(xpath);
}
/**
* @return The value of the {@code jsonPath} attribute
*/
@JsonProperty("jsonpath")
@Override
public Optional getJsonPath() {
return Optional.ofNullable(jsonPath);
}
/**
* @return The value of the {@code regexp} attribute
*/
@JsonProperty("regexp")
@Override
public String getRegexp() {
InitShim shim = this.initShim;
return shim != null
? shim.getRegexp()
: this.regexp;
}
/**
* @return The value of the {@code matchNumber} attribute
*/
@JsonProperty("match_number")
@Override
public @Min(value = -1, groups = {NeoLoad.class}) int getMatchNumber() {
InitShim shim = this.initShim;
return shim != null
? shim.getMatchNumber()
: this.matchNumber;
}
/**
* @return The value of the {@code template} attribute
*/
@JsonProperty("template")
@Override
public String getTemplate() {
InitShim shim = this.initShim;
return shim != null
? shim.getTemplate()
: this.template;
}
/**
* @return The value of the {@code decode} attribute
*/
@JsonProperty("decode")
@Override
public Optional getDecode() {
InitShim shim = this.initShim;
return shim != null
? shim.getDecode()
: this.decode;
}
/**
* @return The value of the {@code extractOnce} attribute
*/
@JsonProperty("extract_once")
@Override
public boolean getExtractOnce() {
InitShim shim = this.initShim;
return shim != null
? shim.getExtractOnce()
: this.extractOnce;
}
/**
* @return The value of the {@code getDefault} attribute
*/
@JsonProperty("default")
@Override
public String getDefault() {
InitShim shim = this.initShim;
return shim != null
? shim.getDefault()
: this.getDefault;
}
/**
* @return The value of the {@code throwAssertionError} attribute
*/
@JsonProperty("throw_assertion_error")
@Override
public boolean getThrowAssertionError() {
InitShim shim = this.initShim;
return shim != null
? shim.getThrowAssertionError()
: this.throwAssertionError;
}
/**
* @return The value of the {@code name} attribute
*/
@JsonProperty("name")
@Override
public String getName() {
return name;
}
/**
* @return The value of the {@code description} attribute
*/
@JsonProperty("description")
@Override
public Optional getDescription() {
return Optional.ofNullable(description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getFrom() from} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for from
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withFrom(VariableExtractor.From value) {
if (this.from == value) return this;
VariableExtractor.From newValue = Objects.requireNonNull(value, "from");
return new ImmutableVariableExtractor(
newValue,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* 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.from,
newValue,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* 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.from,
value,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* 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.from,
this.xpath,
newValue,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* 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.from,
this.xpath,
value,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getRegexp() regexp} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for regexp
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withRegexp(String value) {
if (this.regexp.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "regexp");
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
newValue,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getMatchNumber() matchNumber} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for matchNumber
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withMatchNumber(@Min(value = -1, groups = {NeoLoad.class}) int value) {
if (this.matchNumber == value) return this;
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
value,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getTemplate() template} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for template
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withTemplate(String value) {
if (this.template.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "template");
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
newValue,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getDecode() decode} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for decode
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withDecode(Optional value) {
if (this.decode == value) return this;
Optional newValue = Objects.requireNonNull(value, "decode");
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
newValue,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getExtractOnce() extractOnce} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for extractOnce
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withExtractOnce(boolean value) {
if (this.extractOnce == value) return this;
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
value,
this.getDefault,
this.throwAssertionError,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getDefault() default} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for getDefault
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withDefault(String value) {
if (this.getDefault.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "getDefault");
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
newValue,
this.throwAssertionError,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link VariableExtractor#getThrowAssertionError() throwAssertionError} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for throwAssertionError
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withThrowAssertionError(boolean value) {
if (this.throwAssertionError == value) return this;
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
value,
this.name,
this.description);
}
/**
* 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 (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableVariableExtractor withName(String value) {
if (Objects.equals(this.name, value)) return this;
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
value,
this.description);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link VariableExtractor#getDescription() description} attribute.
* @param value The value for description
* @return A modified copy of {@code this} object
*/
public final ImmutableVariableExtractor withDescription(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "description");
if (Objects.equals(this.description, newValue)) return this;
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link VariableExtractor#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 ImmutableVariableExtractor withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new ImmutableVariableExtractor(
this.from,
this.xpath,
this.jsonPath,
this.regexp,
this.matchNumber,
this.template,
this.decode,
this.extractOnce,
this.getDefault,
this.throwAssertionError,
this.name,
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 from.equals(another.from)
&& Objects.equals(xpath, another.xpath)
&& Objects.equals(jsonPath, another.jsonPath)
&& regexp.equals(another.regexp)
&& matchNumber == another.matchNumber
&& template.equals(another.template)
&& decode.equals(another.decode)
&& extractOnce == another.extractOnce
&& getDefault.equals(another.getDefault)
&& throwAssertionError == another.throwAssertionError
&& Objects.equals(name, another.name)
&& Objects.equals(description, another.description);
}
/**
* Computes a hash code from attributes: {@code from}, {@code xpath}, {@code jsonPath}, {@code regexp}, {@code matchNumber}, {@code template}, {@code decode}, {@code extractOnce}, {@code getDefault}, {@code throwAssertionError}, {@code name}, {@code description}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + from.hashCode();
h += (h << 5) + Objects.hashCode(xpath);
h += (h << 5) + Objects.hashCode(jsonPath);
h += (h << 5) + regexp.hashCode();
h += (h << 5) + matchNumber;
h += (h << 5) + template.hashCode();
h += (h << 5) + decode.hashCode();
h += (h << 5) + Booleans.hashCode(extractOnce);
h += (h << 5) + getDefault.hashCode();
h += (h << 5) + Booleans.hashCode(throwAssertionError);
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(description);
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("from", from)
.add("xpath", xpath)
.add("jsonPath", jsonPath)
.add("regexp", regexp)
.add("matchNumber", matchNumber)
.add("template", template)
.add("decode", decode)
.add("extractOnce", extractOnce)
.add("default", getDefault)
.add("throwAssertionError", throwAssertionError)
.add("name", name)
.add("description", description)
.toString();
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements VariableExtractor {
@Nullable VariableExtractor.From from;
Optional xpath = Optional.empty();
Optional jsonPath = Optional.empty();
@Nullable String regexp;
@Min(value = -1, groups = {NeoLoad.class}) int matchNumber;
boolean matchNumberIsSet;
@Nullable String template;
@Nullable Optional decode;
boolean extractOnce;
boolean extractOnceIsSet;
@Nullable String getDefault;
boolean throwAssertionError;
boolean throwAssertionErrorIsSet;
@Nullable String name;
Optional description = Optional.empty();
@JsonProperty("from")
public void setFrom(VariableExtractor.From from) {
this.from = from;
}
@JsonProperty("xpath")
public void setXpath(Optional xpath) {
this.xpath = xpath;
}
@JsonProperty("jsonpath")
public void setJsonPath(Optional jsonPath) {
this.jsonPath = jsonPath;
}
@JsonProperty("regexp")
public void setRegexp(String regexp) {
this.regexp = regexp;
}
@JsonProperty("match_number")
public void setMatchNumber(@Min(value = -1, groups = {NeoLoad.class}) int matchNumber) {
this.matchNumber = matchNumber;
this.matchNumberIsSet = true;
}
@JsonProperty("template")
public void setTemplate(String template) {
this.template = template;
}
@JsonProperty("decode")
public void setDecode(Optional decode) {
this.decode = decode;
}
@JsonProperty("extract_once")
public void setExtractOnce(boolean extractOnce) {
this.extractOnce = extractOnce;
this.extractOnceIsSet = true;
}
@JsonProperty("default")
public void setDefault(String getDefault) {
this.getDefault = getDefault;
}
@JsonProperty("throw_assertion_error")
public void setThrowAssertionError(boolean throwAssertionError) {
this.throwAssertionError = throwAssertionError;
this.throwAssertionErrorIsSet = true;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("description")
public void setDescription(Optional description) {
this.description = description;
}
@Override
public Element withName(String of) { throw new UnsupportedOperationException(); }
@Override
public VariableExtractor.From getFrom() { throw new UnsupportedOperationException(); }
@Override
public Optional getXpath() { throw new UnsupportedOperationException(); }
@Override
public Optional getJsonPath() { throw new UnsupportedOperationException(); }
@Override
public String getRegexp() { throw new UnsupportedOperationException(); }
@Override
public @Min(value = -1, groups = {NeoLoad.class}) int getMatchNumber() { throw new UnsupportedOperationException(); }
@Override
public String getTemplate() { throw new UnsupportedOperationException(); }
@Override
public Optional getDecode() { throw new UnsupportedOperationException(); }
@Override
public boolean getExtractOnce() { throw new UnsupportedOperationException(); }
@Override
public String getDefault() { throw new UnsupportedOperationException(); }
@Override
public boolean getThrowAssertionError() { throw new UnsupportedOperationException(); }
@Override
public String getName() { throw new UnsupportedOperationException(); }
@Override
public Optional getDescription() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static ImmutableVariableExtractor fromJson(Json json) {
VariableExtractor.Builder builder = new VariableExtractor.Builder();
if (json.from != null) {
builder.from(json.from);
}
if (json.xpath != null) {
builder.xpath(json.xpath);
}
if (json.jsonPath != null) {
builder.jsonPath(json.jsonPath);
}
if (json.regexp != null) {
builder.regexp(json.regexp);
}
if (json.matchNumberIsSet) {
builder.matchNumber(json.matchNumber);
}
if (json.template != null) {
builder.template(json.template);
}
if (json.decode != null) {
builder.decode(json.decode);
}
if (json.extractOnceIsSet) {
builder.extractOnce(json.extractOnce);
}
if (json.getDefault != null) {
builder.getDefault(json.getDefault);
}
if (json.throwAssertionErrorIsSet) {
builder.throwAssertionError(json.throwAssertionError);
}
if (json.name != null) {
builder.name(json.name);
}
if (json.description != null) {
builder.description(json.description);
}
return (ImmutableVariableExtractor) builder.build();
}
/**
* 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 new VariableExtractor.Builder()
.from(instance.getFrom())
.xpath(instance.getXpath())
.jsonPath(instance.getJsonPath())
.regexp(instance.getRegexp())
.matchNumber(instance.getMatchNumber())
.template(instance.getTemplate())
.decode(instance.getDecode())
.extractOnce(instance.getExtractOnce())
.getDefault(instance.getDefault())
.throwAssertionError(instance.getThrowAssertionError())
.name(instance.getName())
.description(instance.getDescription())
.build();
}
/**
* 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 class Builder {
private static final long OPT_BIT_MATCH_NUMBER = 0x1L;
private static final long OPT_BIT_EXTRACT_ONCE = 0x2L;
private static final long OPT_BIT_THROW_ASSERTION_ERROR = 0x4L;
private long optBits;
private @Nullable VariableExtractor.From from;
private @Nullable String xpath;
private @Nullable String jsonPath;
private @Nullable String regexp;
private @Min(value = -1, groups = {NeoLoad.class}) int matchNumber;
private @Nullable String template;
private @Nullable Optional decode;
private boolean extractOnce;
private @Nullable String getDefault;
private boolean throwAssertionError;
private @Nullable String name;
private @Nullable String description;
/**
* Creates a builder for {@link ImmutableVariableExtractor ImmutableVariableExtractor} instances.
*/
public Builder() {
if (!(this instanceof VariableExtractor.Builder)) {
throw new UnsupportedOperationException("Use: new VariableExtractor.Builder()");
}
}
/**
* Initializes the value for the {@link VariableExtractor#getFrom() from} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getFrom() from}.
* @param from The value for from
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("from")
public final VariableExtractor.Builder from(VariableExtractor.From from) {
this.from = Objects.requireNonNull(from, "from");
return (VariableExtractor.Builder) 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 VariableExtractor.Builder xpath(String xpath) {
this.xpath = Objects.requireNonNull(xpath, "xpath");
return (VariableExtractor.Builder) 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
@JsonProperty("xpath")
public final VariableExtractor.Builder xpath(Optional xpath) {
this.xpath = xpath.orElse(null);
return (VariableExtractor.Builder) 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 VariableExtractor.Builder jsonPath(String jsonPath) {
this.jsonPath = Objects.requireNonNull(jsonPath, "jsonPath");
return (VariableExtractor.Builder) 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
@JsonProperty("jsonpath")
public final VariableExtractor.Builder jsonPath(Optional jsonPath) {
this.jsonPath = jsonPath.orElse(null);
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getRegexp() regexp} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getRegexp() regexp}.
* @param regexp The value for regexp
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("regexp")
public final VariableExtractor.Builder regexp(String regexp) {
this.regexp = Objects.requireNonNull(regexp, "regexp");
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getMatchNumber() matchNumber} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getMatchNumber() matchNumber}.
* @param matchNumber The value for matchNumber
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("match_number")
public final VariableExtractor.Builder matchNumber(@Min(value = -1, groups = {NeoLoad.class}) int matchNumber) {
this.matchNumber = matchNumber;
optBits |= OPT_BIT_MATCH_NUMBER;
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getTemplate() template} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getTemplate() template}.
* @param template The value for template
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("template")
public final VariableExtractor.Builder template(String template) {
this.template = Objects.requireNonNull(template, "template");
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getDecode() decode} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getDecode() decode}.
* @param decode The value for decode
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("decode")
public final VariableExtractor.Builder decode(Optional decode) {
this.decode = Objects.requireNonNull(decode, "decode");
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getExtractOnce() extractOnce} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getExtractOnce() extractOnce}.
* @param extractOnce The value for extractOnce
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("extract_once")
public final VariableExtractor.Builder extractOnce(boolean extractOnce) {
this.extractOnce = extractOnce;
optBits |= OPT_BIT_EXTRACT_ONCE;
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getDefault() default} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getDefault() default}.
* @param getDefault The value for getDefault
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("default")
public final VariableExtractor.Builder getDefault(String getDefault) {
this.getDefault = Objects.requireNonNull(getDefault, "getDefault");
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getThrowAssertionError() throwAssertionError} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link VariableExtractor#getThrowAssertionError() throwAssertionError}.
* @param throwAssertionError The value for throwAssertionError
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("throw_assertion_error")
public final VariableExtractor.Builder throwAssertionError(boolean throwAssertionError) {
this.throwAssertionError = throwAssertionError;
optBits |= OPT_BIT_THROW_ASSERTION_ERROR;
return (VariableExtractor.Builder) this;
}
/**
* Initializes the value for the {@link VariableExtractor#getName() name} attribute.
* @param name The value for name (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("name")
public final VariableExtractor.Builder name(String name) {
this.name = name;
return (VariableExtractor.Builder) this;
}
/**
* Initializes the optional value {@link VariableExtractor#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final VariableExtractor.Builder description(String description) {
this.description = Objects.requireNonNull(description, "description");
return (VariableExtractor.Builder) this;
}
/**
* Initializes the optional value {@link VariableExtractor#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("description")
public final VariableExtractor.Builder description(Optional description) {
this.description = description.orElse(null);
return (VariableExtractor.Builder) 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() {
return new ImmutableVariableExtractor(this);
}
private boolean matchNumberIsSet() {
return (optBits & OPT_BIT_MATCH_NUMBER) != 0;
}
private boolean extractOnceIsSet() {
return (optBits & OPT_BIT_EXTRACT_ONCE) != 0;
}
private boolean throwAssertionErrorIsSet() {
return (optBits & OPT_BIT_THROW_ASSERTION_ERROR) != 0;
}
}
}