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

io.resys.hdes.ast.api.nodes.ImmutableCallDef Maven / Gradle / Ivy

package io.resys.hdes.ast.api.nodes;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
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 FlowNode.CallDef}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableCallDef.builder()}. */ @Generated(from = "FlowNode.CallDef", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ImmutableCallDef implements FlowNode.CallDef { private final HdesNode.Token token; private final @Nullable Integer index; private final InvocationNode.SimpleInvocation id; private final MappingNode.ObjectMappingDef mapping; private final Boolean await; private ImmutableCallDef( HdesNode.Token token, @Nullable Integer index, InvocationNode.SimpleInvocation id, MappingNode.ObjectMappingDef mapping, Boolean await) { this.token = token; this.index = index; this.id = id; this.mapping = mapping; this.await = await; } /** * @return The value of the {@code token} attribute */ @Override public HdesNode.Token getToken() { return token; } /** * @return The value of the {@code index} attribute */ @Override public Optional getIndex() { return Optional.ofNullable(index); } /** * @return The value of the {@code id} attribute */ @Override public InvocationNode.SimpleInvocation getId() { return id; } /** * @return The value of the {@code mapping} attribute */ @Override public MappingNode.ObjectMappingDef getMapping() { return mapping; } /** * @return The value of the {@code await} attribute */ @Override public Boolean getAwait() { return await; } /** * Copy the current immutable object by setting a value for the {@link FlowNode.CallDef#getToken() token} 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 token * @return A modified copy of the {@code this} object */ public final ImmutableCallDef withToken(HdesNode.Token value) { if (this.token == value) return this; HdesNode.Token newValue = Objects.requireNonNull(value, "token"); return new ImmutableCallDef(newValue, this.index, this.id, this.mapping, this.await); } /** * Copy the current immutable object by setting a present value for the optional {@link FlowNode.CallDef#getIndex() index} attribute. * @param value The value for index * @return A modified copy of {@code this} object */ public final ImmutableCallDef withIndex(int value) { @Nullable Integer newValue = value; if (Objects.equals(this.index, newValue)) return this; return new ImmutableCallDef(this.token, newValue, this.id, this.mapping, this.await); } /** * Copy the current immutable object by setting an optional value for the {@link FlowNode.CallDef#getIndex() index} 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 index * @return A modified copy of {@code this} object */ public final ImmutableCallDef withIndex(Optional optional) { @Nullable Integer value = optional.orElse(null); if (Objects.equals(this.index, value)) return this; return new ImmutableCallDef(this.token, value, this.id, this.mapping, this.await); } /** * Copy the current immutable object by setting a value for the {@link FlowNode.CallDef#getId() id} 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 id * @return A modified copy of the {@code this} object */ public final ImmutableCallDef withId(InvocationNode.SimpleInvocation value) { if (this.id == value) return this; InvocationNode.SimpleInvocation newValue = Objects.requireNonNull(value, "id"); return new ImmutableCallDef(this.token, this.index, newValue, this.mapping, this.await); } /** * Copy the current immutable object by setting a value for the {@link FlowNode.CallDef#getMapping() mapping} 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 mapping * @return A modified copy of the {@code this} object */ public final ImmutableCallDef withMapping(MappingNode.ObjectMappingDef value) { if (this.mapping == value) return this; MappingNode.ObjectMappingDef newValue = Objects.requireNonNull(value, "mapping"); return new ImmutableCallDef(this.token, this.index, this.id, newValue, this.await); } /** * Copy the current immutable object by setting a value for the {@link FlowNode.CallDef#getAwait() await} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for await * @return A modified copy of the {@code this} object */ public final ImmutableCallDef withAwait(Boolean value) { Boolean newValue = Objects.requireNonNull(value, "await"); if (this.await.equals(newValue)) return this; return new ImmutableCallDef(this.token, this.index, this.id, this.mapping, newValue); } /** * This instance is equal to all instances of {@code ImmutableCallDef} 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 ImmutableCallDef && equalTo((ImmutableCallDef) another); } private boolean equalTo(ImmutableCallDef another) { return token.equals(another.token) && Objects.equals(index, another.index) && id.equals(another.id) && mapping.equals(another.mapping) && await.equals(another.await); } /** * Computes a hash code from attributes: {@code token}, {@code index}, {@code id}, {@code mapping}, {@code await}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + token.hashCode(); h += (h << 5) + Objects.hashCode(index); h += (h << 5) + id.hashCode(); h += (h << 5) + mapping.hashCode(); h += (h << 5) + await.hashCode(); return h; } /** * Prints the immutable value {@code CallDef} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("CallDef{"); builder.append("token=").append(token); if (index != null) { builder.append(", "); builder.append("index=").append(index); } builder.append(", "); builder.append("id=").append(id); builder.append(", "); builder.append("mapping=").append(mapping); builder.append(", "); builder.append("await=").append(await); return builder.append("}").toString(); } /** * Creates an immutable copy of a {@link FlowNode.CallDef} 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 CallDef instance */ public static ImmutableCallDef copyOf(FlowNode.CallDef instance) { if (instance instanceof ImmutableCallDef) { return (ImmutableCallDef) instance; } return ImmutableCallDef.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableCallDef ImmutableCallDef}. *

   * ImmutableCallDef.builder()
   *    .token(io.resys.hdes.ast.api.nodes.HdesNode.Token) // required {@link FlowNode.CallDef#getToken() token}
   *    .index(Integer) // optional {@link FlowNode.CallDef#getIndex() index}
   *    .id(io.resys.hdes.ast.api.nodes.InvocationNode.SimpleInvocation) // required {@link FlowNode.CallDef#getId() id}
   *    .mapping(io.resys.hdes.ast.api.nodes.MappingNode.ObjectMappingDef) // required {@link FlowNode.CallDef#getMapping() mapping}
   *    .await(Boolean) // required {@link FlowNode.CallDef#getAwait() await}
   *    .build();
   * 
* @return A new ImmutableCallDef builder */ public static ImmutableCallDef.Builder builder() { return new ImmutableCallDef.Builder(); } /** * Builds instances of type {@link ImmutableCallDef ImmutableCallDef}. * 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 = "FlowNode.CallDef", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_TOKEN = 0x1L; private static final long INIT_BIT_ID = 0x2L; private static final long INIT_BIT_MAPPING = 0x4L; private static final long INIT_BIT_AWAIT = 0x8L; private long initBits = 0xfL; private @Nullable HdesNode.Token token; private @Nullable Integer index; private @Nullable InvocationNode.SimpleInvocation id; private @Nullable MappingNode.ObjectMappingDef mapping; private @Nullable Boolean await; private Builder() { } /** * Fill a builder with attribute values from the provided {@code io.resys.hdes.ast.api.nodes.HdesNode} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(HdesNode instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code io.resys.hdes.ast.api.nodes.FlowNode.CallDef} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(FlowNode.CallDef instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof HdesNode) { HdesNode instance = (HdesNode) object; token(instance.getToken()); } if (object instanceof FlowNode.CallDef) { FlowNode.CallDef instance = (FlowNode.CallDef) object; await(instance.getAwait()); Optional indexOptional = instance.getIndex(); if (indexOptional.isPresent()) { index(indexOptional); } mapping(instance.getMapping()); id(instance.getId()); } } /** * Initializes the value for the {@link FlowNode.CallDef#getToken() token} attribute. * @param token The value for token * @return {@code this} builder for use in a chained invocation */ public final Builder token(HdesNode.Token token) { this.token = Objects.requireNonNull(token, "token"); initBits &= ~INIT_BIT_TOKEN; return this; } /** * Initializes the optional value {@link FlowNode.CallDef#getIndex() index} to index. * @param index The value for index * @return {@code this} builder for chained invocation */ public final Builder index(int index) { this.index = index; return this; } /** * Initializes the optional value {@link FlowNode.CallDef#getIndex() index} to index. * @param index The value for index * @return {@code this} builder for use in a chained invocation */ public final Builder index(Optional index) { this.index = index.orElse(null); return this; } /** * Initializes the value for the {@link FlowNode.CallDef#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ public final Builder id(InvocationNode.SimpleInvocation id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Initializes the value for the {@link FlowNode.CallDef#getMapping() mapping} attribute. * @param mapping The value for mapping * @return {@code this} builder for use in a chained invocation */ public final Builder mapping(MappingNode.ObjectMappingDef mapping) { this.mapping = Objects.requireNonNull(mapping, "mapping"); initBits &= ~INIT_BIT_MAPPING; return this; } /** * Initializes the value for the {@link FlowNode.CallDef#getAwait() await} attribute. * @param await The value for await * @return {@code this} builder for use in a chained invocation */ public final Builder await(Boolean await) { this.await = Objects.requireNonNull(await, "await"); initBits &= ~INIT_BIT_AWAIT; return this; } /** * Builds a new {@link ImmutableCallDef ImmutableCallDef}. * @return An immutable instance of CallDef * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCallDef build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableCallDef(token, index, id, mapping, await); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_TOKEN) != 0) attributes.add("token"); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_MAPPING) != 0) attributes.add("mapping"); if ((initBits & INIT_BIT_AWAIT) != 0) attributes.add("await"); return "Cannot build CallDef, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy