All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.resys.hdes.client.api.ast.ImmutableAstFlow Maven / Gradle / Ivy

There is a newer version: 3.130.78
Show newest version
package io.resys.hdes.client.api.ast;

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.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link AstFlow}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableAstFlow.builder()}. */ @Generated(from = "AstFlow", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableAstFlow implements AstFlow { private final String name; private final @Nullable String description; private final AstBody.Headers headers; private final AstBody.AstBodyType bodyType; private final ImmutableList messages; private final AstFlow.AstFlowRoot src; private final ImmutableList autocomplete; private ImmutableAstFlow( String name, @Nullable String description, AstBody.Headers headers, AstBody.AstBodyType bodyType, ImmutableList messages, AstFlow.AstFlowRoot src, ImmutableList autocomplete) { this.name = name; this.description = description; this.headers = headers; this.bodyType = bodyType; this.messages = messages; this.src = src; this.autocomplete = autocomplete; } /** * @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 @Nullable String getDescription() { return description; } /** * @return The value of the {@code headers} attribute */ @JsonProperty("headers") @Override public AstBody.Headers getHeaders() { return headers; } /** * @return The value of the {@code bodyType} attribute */ @JsonProperty("bodyType") @Override public AstBody.AstBodyType getBodyType() { return bodyType; } /** * @return The value of the {@code messages} attribute */ @JsonProperty("messages") @Override public ImmutableList getMessages() { return messages; } /** * @return The value of the {@code src} attribute */ @JsonProperty("src") @Override public AstFlow.AstFlowRoot getSrc() { return src; } /** * @return The value of the {@code autocomplete} attribute */ @JsonProperty("autocomplete") @Override public ImmutableList getAutocomplete() { return autocomplete; } /** * Copy the current immutable object by setting a value for the {@link AstFlow#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 ImmutableAstFlow withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new ImmutableAstFlow( newValue, this.description, this.headers, this.bodyType, this.messages, this.src, this.autocomplete); } /** * Copy the current immutable object by setting a value for the {@link AstFlow#getDescription() description} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for description (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableAstFlow withDescription(@Nullable String value) { if (Objects.equals(this.description, value)) return this; return new ImmutableAstFlow(this.name, value, this.headers, this.bodyType, this.messages, this.src, this.autocomplete); } /** * Copy the current immutable object by setting a value for the {@link AstFlow#getHeaders() headers} 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 headers * @return A modified copy of the {@code this} object */ public final ImmutableAstFlow withHeaders(AstBody.Headers value) { if (this.headers == value) return this; AstBody.Headers newValue = Objects.requireNonNull(value, "headers"); return new ImmutableAstFlow( this.name, this.description, newValue, this.bodyType, this.messages, this.src, this.autocomplete); } /** * Copy the current immutable object by setting a value for the {@link AstFlow#getBodyType() bodyType} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for bodyType * @return A modified copy of the {@code this} object */ public final ImmutableAstFlow withBodyType(AstBody.AstBodyType value) { if (this.bodyType == value) return this; AstBody.AstBodyType newValue = Objects.requireNonNull(value, "bodyType"); if (this.bodyType.equals(newValue)) return this; return new ImmutableAstFlow(this.name, this.description, this.headers, newValue, this.messages, this.src, this.autocomplete); } /** * Copy the current immutable object with elements that replace the content of {@link AstFlow#getMessages() messages}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableAstFlow withMessages(AstBody.AstCommandMessage... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAstFlow(this.name, this.description, this.headers, this.bodyType, newValue, this.src, this.autocomplete); } /** * Copy the current immutable object with elements that replace the content of {@link AstFlow#getMessages() messages}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of messages elements to set * @return A modified copy of {@code this} object */ public final ImmutableAstFlow withMessages(Iterable elements) { if (this.messages == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAstFlow(this.name, this.description, this.headers, this.bodyType, newValue, this.src, this.autocomplete); } /** * Copy the current immutable object by setting a value for the {@link AstFlow#getSrc() src} 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 src * @return A modified copy of the {@code this} object */ public final ImmutableAstFlow withSrc(AstFlow.AstFlowRoot value) { if (this.src == value) return this; AstFlow.AstFlowRoot newValue = Objects.requireNonNull(value, "src"); return new ImmutableAstFlow( this.name, this.description, this.headers, this.bodyType, this.messages, newValue, this.autocomplete); } /** * Copy the current immutable object with elements that replace the content of {@link AstFlow#getAutocomplete() autocomplete}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableAstFlow withAutocomplete(AstFlow.FlowAstAutocomplete... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAstFlow(this.name, this.description, this.headers, this.bodyType, this.messages, this.src, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link AstFlow#getAutocomplete() autocomplete}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of autocomplete elements to set * @return A modified copy of {@code this} object */ public final ImmutableAstFlow withAutocomplete(Iterable elements) { if (this.autocomplete == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAstFlow(this.name, this.description, this.headers, this.bodyType, this.messages, this.src, newValue); } /** * This instance is equal to all instances of {@code ImmutableAstFlow} 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 ImmutableAstFlow && equalTo((ImmutableAstFlow) another); } private boolean equalTo(ImmutableAstFlow another) { return name.equals(another.name) && Objects.equals(description, another.description) && headers.equals(another.headers) && bodyType.equals(another.bodyType) && messages.equals(another.messages) && src.equals(another.src) && autocomplete.equals(another.autocomplete); } /** * Computes a hash code from attributes: {@code name}, {@code description}, {@code headers}, {@code bodyType}, {@code messages}, {@code src}, {@code autocomplete}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(description); h += (h << 5) + headers.hashCode(); h += (h << 5) + bodyType.hashCode(); h += (h << 5) + messages.hashCode(); h += (h << 5) + src.hashCode(); h += (h << 5) + autocomplete.hashCode(); return h; } /** * Prints the immutable value {@code AstFlow} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("AstFlow") .omitNullValues() .add("name", name) .add("description", description) .add("headers", headers) .add("bodyType", bodyType) .add("messages", messages) .add("src", src) .add("autocomplete", autocomplete) .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 */ @Generated(from = "AstFlow", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements AstFlow { @Nullable String name; @Nullable String description; @Nullable AstBody.Headers headers; @Nullable AstBody.AstBodyType bodyType; @Nullable List messages = ImmutableList.of(); @Nullable AstFlow.AstFlowRoot src; @Nullable List autocomplete = ImmutableList.of(); @JsonProperty("name") public void setName(String name) { this.name = name; } @JsonProperty("description") public void setDescription(@Nullable String description) { this.description = description; } @JsonProperty("headers") public void setHeaders(AstBody.Headers headers) { this.headers = headers; } @JsonProperty("bodyType") public void setBodyType(AstBody.AstBodyType bodyType) { this.bodyType = bodyType; } @JsonProperty("messages") public void setMessages(List messages) { this.messages = messages; } @JsonProperty("src") public void setSrc(AstFlow.AstFlowRoot src) { this.src = src; } @JsonProperty("autocomplete") public void setAutocomplete(List autocomplete) { this.autocomplete = autocomplete; } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public String getDescription() { throw new UnsupportedOperationException(); } @Override public AstBody.Headers getHeaders() { throw new UnsupportedOperationException(); } @Override public AstBody.AstBodyType getBodyType() { throw new UnsupportedOperationException(); } @Override public List getMessages() { throw new UnsupportedOperationException(); } @Override public AstFlow.AstFlowRoot getSrc() { throw new UnsupportedOperationException(); } @Override public List getAutocomplete() { 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 ImmutableAstFlow fromJson(Json json) { ImmutableAstFlow.Builder builder = ImmutableAstFlow.builder(); if (json.name != null) { builder.name(json.name); } if (json.description != null) { builder.description(json.description); } if (json.headers != null) { builder.headers(json.headers); } if (json.bodyType != null) { builder.bodyType(json.bodyType); } if (json.messages != null) { builder.addAllMessages(json.messages); } if (json.src != null) { builder.src(json.src); } if (json.autocomplete != null) { builder.addAllAutocomplete(json.autocomplete); } return builder.build(); } /** * Creates an immutable copy of a {@link AstFlow} 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 AstFlow instance */ public static ImmutableAstFlow copyOf(AstFlow instance) { if (instance instanceof ImmutableAstFlow) { return (ImmutableAstFlow) instance; } return ImmutableAstFlow.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableAstFlow ImmutableAstFlow}. *

   * ImmutableAstFlow.builder()
   *    .name(String) // required {@link AstFlow#getName() name}
   *    .description(String | null) // nullable {@link AstFlow#getDescription() description}
   *    .headers(io.resys.hdes.client.api.ast.AstBody.Headers) // required {@link AstFlow#getHeaders() headers}
   *    .bodyType(io.resys.hdes.client.api.ast.AstBody.AstBodyType) // required {@link AstFlow#getBodyType() bodyType}
   *    .addMessages|addAllMessages(io.resys.hdes.client.api.ast.AstBody.AstCommandMessage) // {@link AstFlow#getMessages() messages} elements
   *    .src(io.resys.hdes.client.api.ast.AstFlow.AstFlowRoot) // required {@link AstFlow#getSrc() src}
   *    .addAutocomplete|addAllAutocomplete(io.resys.hdes.client.api.ast.AstFlow.FlowAstAutocomplete) // {@link AstFlow#getAutocomplete() autocomplete} elements
   *    .build();
   * 
* @return A new ImmutableAstFlow builder */ public static ImmutableAstFlow.Builder builder() { return new ImmutableAstFlow.Builder(); } /** * Builds instances of type {@link ImmutableAstFlow ImmutableAstFlow}. * 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. */ @Generated(from = "AstFlow", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private static final long INIT_BIT_HEADERS = 0x2L; private static final long INIT_BIT_BODY_TYPE = 0x4L; private static final long INIT_BIT_SRC = 0x8L; private long initBits = 0xfL; private @Nullable String name; private @Nullable String description; private @Nullable AstBody.Headers headers; private @Nullable AstBody.AstBodyType bodyType; private ImmutableList.Builder messages = ImmutableList.builder(); private @Nullable AstFlow.AstFlowRoot src; private ImmutableList.Builder autocomplete = ImmutableList.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code io.resys.hdes.client.api.ast.AstFlow} 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(AstFlow instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code io.resys.hdes.client.api.ast.AstBody} 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(AstBody instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof AstFlow) { AstFlow instance = (AstFlow) object; src(instance.getSrc()); addAllAutocomplete(instance.getAutocomplete()); } if (object instanceof AstBody) { AstBody instance = (AstBody) object; bodyType(instance.getBodyType()); name(instance.getName()); headers(instance.getHeaders()); @Nullable String descriptionValue = instance.getDescription(); if (descriptionValue != null) { description(descriptionValue); } addAllMessages(instance.getMessages()); } } /** * Initializes the value for the {@link AstFlow#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 value for the {@link AstFlow#getDescription() description} attribute. * @param description The value for description (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("description") public final Builder description(@Nullable String description) { this.description = description; return this; } /** * Initializes the value for the {@link AstFlow#getHeaders() headers} attribute. * @param headers The value for headers * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("headers") public final Builder headers(AstBody.Headers headers) { this.headers = Objects.requireNonNull(headers, "headers"); initBits &= ~INIT_BIT_HEADERS; return this; } /** * Initializes the value for the {@link AstFlow#getBodyType() bodyType} attribute. * @param bodyType The value for bodyType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("bodyType") public final Builder bodyType(AstBody.AstBodyType bodyType) { this.bodyType = Objects.requireNonNull(bodyType, "bodyType"); initBits &= ~INIT_BIT_BODY_TYPE; return this; } /** * Adds one element to {@link AstFlow#getMessages() messages} list. * @param element A messages element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMessages(AstBody.AstCommandMessage element) { this.messages.add(element); return this; } /** * Adds elements to {@link AstFlow#getMessages() messages} list. * @param elements An array of messages elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMessages(AstBody.AstCommandMessage... elements) { this.messages.add(elements); return this; } /** * Sets or replaces all elements for {@link AstFlow#getMessages() messages} list. * @param elements An iterable of messages elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("messages") public final Builder messages(Iterable elements) { this.messages = ImmutableList.builder(); return addAllMessages(elements); } /** * Adds elements to {@link AstFlow#getMessages() messages} list. * @param elements An iterable of messages elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllMessages(Iterable elements) { this.messages.addAll(elements); return this; } /** * Initializes the value for the {@link AstFlow#getSrc() src} attribute. * @param src The value for src * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("src") public final Builder src(AstFlow.AstFlowRoot src) { this.src = Objects.requireNonNull(src, "src"); initBits &= ~INIT_BIT_SRC; return this; } /** * Adds one element to {@link AstFlow#getAutocomplete() autocomplete} list. * @param element A autocomplete element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAutocomplete(AstFlow.FlowAstAutocomplete element) { this.autocomplete.add(element); return this; } /** * Adds elements to {@link AstFlow#getAutocomplete() autocomplete} list. * @param elements An array of autocomplete elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAutocomplete(AstFlow.FlowAstAutocomplete... elements) { this.autocomplete.add(elements); return this; } /** * Sets or replaces all elements for {@link AstFlow#getAutocomplete() autocomplete} list. * @param elements An iterable of autocomplete elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("autocomplete") public final Builder autocomplete(Iterable elements) { this.autocomplete = ImmutableList.builder(); return addAllAutocomplete(elements); } /** * Adds elements to {@link AstFlow#getAutocomplete() autocomplete} list. * @param elements An iterable of autocomplete elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAutocomplete(Iterable elements) { this.autocomplete.addAll(elements); return this; } /** * Builds a new {@link ImmutableAstFlow ImmutableAstFlow}. * @return An immutable instance of AstFlow * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableAstFlow build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableAstFlow(name, description, headers, bodyType, messages.build(), src, autocomplete.build()); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_HEADERS) != 0) attributes.add("headers"); if ((initBits & INIT_BIT_BODY_TYPE) != 0) attributes.add("bodyType"); if ((initBits & INIT_BIT_SRC) != 0) attributes.add("src"); return "Cannot build AstFlow, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy