com.neotys.neoload.model.repository.ImmutableAddCookie Maven / Gradle / Ivy
package com.neotys.neoload.model.repository;
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.errorprone.annotations.CanIgnoreReturnValue;
import com.neotys.neoload.model.core.Element;
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 AddCookie}.
*
* Use the builder to create immutable instances:
* {@code ImmutableAddCookie.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "AddCookie"})
@Deprecated
@Immutable
@CheckReturnValue
public final class ImmutableAddCookie implements AddCookie {
private final String cookieName;
private final String cookieValue;
private final Server server;
private final @Nullable String expires;
private final @Nullable String path;
private final String name;
private final @Nullable String description;
private ImmutableAddCookie(
String cookieName,
String cookieValue,
Server server,
@Nullable String expires,
@Nullable String path,
String name,
@Nullable String description) {
this.cookieName = cookieName;
this.cookieValue = cookieValue;
this.server = server;
this.expires = expires;
this.path = path;
this.name = name;
this.description = description;
}
/**
* @return The value of the {@code cookieName} attribute
*/
@JsonProperty("cookieName")
@Override
public String getCookieName() {
return cookieName;
}
/**
* @return The value of the {@code cookieValue} attribute
*/
@JsonProperty("cookieValue")
@Override
public String getCookieValue() {
return cookieValue;
}
/**
* @return The value of the {@code server} attribute
*/
@JsonProperty("server")
@Override
public Server getServer() {
return server;
}
/**
* @return The value of the {@code expires} attribute
*/
@JsonProperty("expires")
@Override
public Optional getExpires() {
return Optional.ofNullable(expires);
}
/**
* @return The value of the {@code path} attribute
*/
@JsonProperty("path")
@Override
public Optional getPath() {
return Optional.ofNullable(path);
}
/**
* @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 AddCookie#getCookieName() cookieName} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for cookieName
* @return A modified copy of the {@code this} object
*/
public final ImmutableAddCookie withCookieName(String value) {
if (this.cookieName.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "cookieName");
return new ImmutableAddCookie(newValue, this.cookieValue, this.server, this.expires, this.path, this.name, this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link AddCookie#getCookieValue() cookieValue} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for cookieValue
* @return A modified copy of the {@code this} object
*/
public final ImmutableAddCookie withCookieValue(String value) {
if (this.cookieValue.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "cookieValue");
return new ImmutableAddCookie(this.cookieName, newValue, this.server, this.expires, this.path, this.name, this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link AddCookie#getServer() server} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for server
* @return A modified copy of the {@code this} object
*/
public final ImmutableAddCookie withServer(Server value) {
if (this.server == value) return this;
Server newValue = Objects.requireNonNull(value, "server");
return new ImmutableAddCookie(
this.cookieName,
this.cookieValue,
newValue,
this.expires,
this.path,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AddCookie#getExpires() expires} attribute.
* @param value The value for expires
* @return A modified copy of {@code this} object
*/
public final ImmutableAddCookie withExpires(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "expires");
if (Objects.equals(this.expires, newValue)) return this;
return new ImmutableAddCookie(
this.cookieName,
this.cookieValue,
this.server,
newValue,
this.path,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting an optional value for the {@link AddCookie#getExpires() expires} 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 expires
* @return A modified copy of {@code this} object
*/
public final ImmutableAddCookie withExpires(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.expires, value)) return this;
return new ImmutableAddCookie(this.cookieName, this.cookieValue, this.server, value, this.path, this.name, this.description);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AddCookie#getPath() path} attribute.
* @param value The value for path
* @return A modified copy of {@code this} object
*/
public final ImmutableAddCookie withPath(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "path");
if (Objects.equals(this.path, newValue)) return this;
return new ImmutableAddCookie(
this.cookieName,
this.cookieValue,
this.server,
this.expires,
newValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting an optional value for the {@link AddCookie#getPath() path} 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 path
* @return A modified copy of {@code this} object
*/
public final ImmutableAddCookie withPath(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.path, value)) return this;
return new ImmutableAddCookie(
this.cookieName,
this.cookieValue,
this.server,
this.expires,
value,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link AddCookie#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 ImmutableAddCookie withName(String value) {
if (this.name.equals(value)) return this;
String newValue = Objects.requireNonNull(value, "name");
return new ImmutableAddCookie(
this.cookieName,
this.cookieValue,
this.server,
this.expires,
this.path,
newValue,
this.description);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AddCookie#getDescription() description} attribute.
* @param value The value for description
* @return A modified copy of {@code this} object
*/
public final ImmutableAddCookie withDescription(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "description");
if (Objects.equals(this.description, newValue)) return this;
return new ImmutableAddCookie(this.cookieName, this.cookieValue, this.server, this.expires, this.path, this.name, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link AddCookie#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 ImmutableAddCookie withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new ImmutableAddCookie(this.cookieName, this.cookieValue, this.server, this.expires, this.path, this.name, value);
}
/**
* This instance is equal to all instances of {@code ImmutableAddCookie} 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 ImmutableAddCookie
&& equalTo((ImmutableAddCookie) another);
}
private boolean equalTo(ImmutableAddCookie another) {
return cookieName.equals(another.cookieName)
&& cookieValue.equals(another.cookieValue)
&& server.equals(another.server)
&& Objects.equals(expires, another.expires)
&& Objects.equals(path, another.path)
&& name.equals(another.name)
&& Objects.equals(description, another.description);
}
/**
* Computes a hash code from attributes: {@code cookieName}, {@code cookieValue}, {@code server}, {@code expires}, {@code path}, {@code name}, {@code description}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + cookieName.hashCode();
h += (h << 5) + cookieValue.hashCode();
h += (h << 5) + server.hashCode();
h += (h << 5) + Objects.hashCode(expires);
h += (h << 5) + Objects.hashCode(path);
h += (h << 5) + name.hashCode();
h += (h << 5) + Objects.hashCode(description);
return h;
}
/**
* Prints the immutable value {@code AddCookie} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("AddCookie")
.omitNullValues()
.add("cookieName", cookieName)
.add("cookieValue", cookieValue)
.add("server", server)
.add("expires", expires)
.add("path", path)
.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 AddCookie {
@Nullable String cookieName;
@Nullable String cookieValue;
@Nullable Server server;
Optional expires = Optional.empty();
Optional path = Optional.empty();
@Nullable String name;
Optional description = Optional.empty();
@JsonProperty("cookieName")
public void setCookieName(String cookieName) {
this.cookieName = cookieName;
}
@JsonProperty("cookieValue")
public void setCookieValue(String cookieValue) {
this.cookieValue = cookieValue;
}
@JsonProperty("server")
public void setServer(Server server) {
this.server = server;
}
@JsonProperty("expires")
public void setExpires(Optional expires) {
this.expires = expires;
}
@JsonProperty("path")
public void setPath(Optional path) {
this.path = path;
}
@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 String getCookieName() { throw new UnsupportedOperationException(); }
@Override
public String getCookieValue() { throw new UnsupportedOperationException(); }
@Override
public Server getServer() { throw new UnsupportedOperationException(); }
@Override
public Optional getExpires() { throw new UnsupportedOperationException(); }
@Override
public Optional getPath() { 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 ImmutableAddCookie fromJson(Json json) {
ImmutableAddCookie.Builder builder = ImmutableAddCookie.builder();
if (json.cookieName != null) {
builder.cookieName(json.cookieName);
}
if (json.cookieValue != null) {
builder.cookieValue(json.cookieValue);
}
if (json.server != null) {
builder.server(json.server);
}
if (json.expires != null) {
builder.expires(json.expires);
}
if (json.path != null) {
builder.path(json.path);
}
if (json.name != null) {
builder.name(json.name);
}
if (json.description != null) {
builder.description(json.description);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link AddCookie} 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 AddCookie instance
*/
public static ImmutableAddCookie copyOf(AddCookie instance) {
if (instance instanceof ImmutableAddCookie) {
return (ImmutableAddCookie) instance;
}
return ImmutableAddCookie.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableAddCookie ImmutableAddCookie}.
* @return A new ImmutableAddCookie builder
*/
public static ImmutableAddCookie.Builder builder() {
return new ImmutableAddCookie.Builder();
}
/**
* Builds instances of type {@link ImmutableAddCookie ImmutableAddCookie}.
* 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_COOKIE_NAME = 0x1L;
private static final long INIT_BIT_COOKIE_VALUE = 0x2L;
private static final long INIT_BIT_SERVER = 0x4L;
private static final long INIT_BIT_NAME = 0x8L;
private long initBits = 0xfL;
private @Nullable String cookieName;
private @Nullable String cookieValue;
private @Nullable Server server;
private @Nullable String expires;
private @Nullable String path;
private @Nullable String name;
private @Nullable String description;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.repository.AddCookie} 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(AddCookie instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.core.Element} 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(Element instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
private void from(Object object) {
if (object instanceof AddCookie) {
AddCookie instance = (AddCookie) object;
server(instance.getServer());
Optional pathOptional = instance.getPath();
if (pathOptional.isPresent()) {
path(pathOptional);
}
cookieValue(instance.getCookieValue());
Optional expiresOptional = instance.getExpires();
if (expiresOptional.isPresent()) {
expires(expiresOptional);
}
cookieName(instance.getCookieName());
}
if (object instanceof Element) {
Element instance = (Element) object;
name(instance.getName());
Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
description(descriptionOptional);
}
}
}
/**
* Initializes the value for the {@link AddCookie#getCookieName() cookieName} attribute.
* @param cookieName The value for cookieName
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("cookieName")
public final Builder cookieName(String cookieName) {
this.cookieName = Objects.requireNonNull(cookieName, "cookieName");
initBits &= ~INIT_BIT_COOKIE_NAME;
return this;
}
/**
* Initializes the value for the {@link AddCookie#getCookieValue() cookieValue} attribute.
* @param cookieValue The value for cookieValue
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("cookieValue")
public final Builder cookieValue(String cookieValue) {
this.cookieValue = Objects.requireNonNull(cookieValue, "cookieValue");
initBits &= ~INIT_BIT_COOKIE_VALUE;
return this;
}
/**
* Initializes the value for the {@link AddCookie#getServer() server} attribute.
* @param server The value for server
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("server")
public final Builder server(Server server) {
this.server = Objects.requireNonNull(server, "server");
initBits &= ~INIT_BIT_SERVER;
return this;
}
/**
* Initializes the optional value {@link AddCookie#getExpires() expires} to expires.
* @param expires The value for expires
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder expires(String expires) {
this.expires = Objects.requireNonNull(expires, "expires");
return this;
}
/**
* Initializes the optional value {@link AddCookie#getExpires() expires} to expires.
* @param expires The value for expires
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("expires")
public final Builder expires(Optional expires) {
this.expires = expires.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AddCookie#getPath() path} to path.
* @param path The value for path
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder path(String path) {
this.path = Objects.requireNonNull(path, "path");
return this;
}
/**
* Initializes the optional value {@link AddCookie#getPath() path} to path.
* @param path The value for path
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("path")
public final Builder path(Optional path) {
this.path = path.orElse(null);
return this;
}
/**
* Initializes the value for the {@link AddCookie#getName() name} attribute.
* @param name The value for name
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("name")
public final Builder name(String name) {
this.name = Objects.requireNonNull(name, "name");
initBits &= ~INIT_BIT_NAME;
return this;
}
/**
* Initializes the optional value {@link AddCookie#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 AddCookie#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 Builder description(Optional description) {
this.description = description.orElse(null);
return this;
}
/**
* Builds a new {@link ImmutableAddCookie ImmutableAddCookie}.
* @return An immutable instance of AddCookie
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableAddCookie build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableAddCookie(cookieName, cookieValue, server, expires, path, name, description);
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_COOKIE_NAME) != 0) attributes.add("cookieName");
if ((initBits & INIT_BIT_COOKIE_VALUE) != 0) attributes.add("cookieValue");
if ((initBits & INIT_BIT_SERVER) != 0) attributes.add("server");
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
return "Cannot build AddCookie, some of required attributes are not set " + attributes;
}
}
}