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

io.resys.hdes.client.api.ast.ImmutableAstDecisionRow 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 AstDecision.AstDecisionRow}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableAstDecisionRow.builder()}. */ @Generated(from = "AstDecision.AstDecisionRow", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableAstDecisionRow implements AstDecision.AstDecisionRow { private final String id; private final int order; private final ImmutableList cells; private ImmutableAstDecisionRow( String id, int order, ImmutableList cells) { this.id = id; this.order = order; this.cells = cells; } /** * @return The value of the {@code id} attribute */ @JsonProperty("id") @Override public String getId() { return id; } /** * @return The value of the {@code order} attribute */ @JsonProperty("order") @Override public int getOrder() { return order; } /** * @return The value of the {@code cells} attribute */ @JsonProperty("cells") @Override public ImmutableList getCells() { return cells; } /** * Copy the current immutable object by setting a value for the {@link AstDecision.AstDecisionRow#getId() id} attribute. * An equals check 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 ImmutableAstDecisionRow withId(String value) { String newValue = Objects.requireNonNull(value, "id"); if (this.id.equals(newValue)) return this; return new ImmutableAstDecisionRow(newValue, this.order, this.cells); } /** * Copy the current immutable object by setting a value for the {@link AstDecision.AstDecisionRow#getOrder() order} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for order * @return A modified copy of the {@code this} object */ public final ImmutableAstDecisionRow withOrder(int value) { if (this.order == value) return this; return new ImmutableAstDecisionRow(this.id, value, this.cells); } /** * Copy the current immutable object with elements that replace the content of {@link AstDecision.AstDecisionRow#getCells() cells}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableAstDecisionRow withCells(AstDecision.AstDecisionCell... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAstDecisionRow(this.id, this.order, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link AstDecision.AstDecisionRow#getCells() cells}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of cells elements to set * @return A modified copy of {@code this} object */ public final ImmutableAstDecisionRow withCells(Iterable elements) { if (this.cells == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAstDecisionRow(this.id, this.order, newValue); } /** * This instance is equal to all instances of {@code ImmutableAstDecisionRow} 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 ImmutableAstDecisionRow && equalTo((ImmutableAstDecisionRow) another); } private boolean equalTo(ImmutableAstDecisionRow another) { return id.equals(another.id) && order == another.order && cells.equals(another.cells); } /** * Computes a hash code from attributes: {@code id}, {@code order}, {@code cells}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + id.hashCode(); h += (h << 5) + order; h += (h << 5) + cells.hashCode(); return h; } /** * Prints the immutable value {@code AstDecisionRow} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("AstDecisionRow") .omitNullValues() .add("id", id) .add("order", order) .add("cells", cells) .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 = "AstDecision.AstDecisionRow", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements AstDecision.AstDecisionRow { @Nullable String id; int order; boolean orderIsSet; @Nullable List cells = ImmutableList.of(); @JsonProperty("id") public void setId(String id) { this.id = id; } @JsonProperty("order") public void setOrder(int order) { this.order = order; this.orderIsSet = true; } @JsonProperty("cells") public void setCells(List cells) { this.cells = cells; } @Override public String getId() { throw new UnsupportedOperationException(); } @Override public int getOrder() { throw new UnsupportedOperationException(); } @Override public List getCells() { 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 ImmutableAstDecisionRow fromJson(Json json) { ImmutableAstDecisionRow.Builder builder = ImmutableAstDecisionRow.builder(); if (json.id != null) { builder.id(json.id); } if (json.orderIsSet) { builder.order(json.order); } if (json.cells != null) { builder.addAllCells(json.cells); } return builder.build(); } /** * Creates an immutable copy of a {@link AstDecision.AstDecisionRow} 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 AstDecisionRow instance */ public static ImmutableAstDecisionRow copyOf(AstDecision.AstDecisionRow instance) { if (instance instanceof ImmutableAstDecisionRow) { return (ImmutableAstDecisionRow) instance; } return ImmutableAstDecisionRow.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableAstDecisionRow ImmutableAstDecisionRow}. *

   * ImmutableAstDecisionRow.builder()
   *    .id(String) // required {@link AstDecision.AstDecisionRow#getId() id}
   *    .order(int) // required {@link AstDecision.AstDecisionRow#getOrder() order}
   *    .addCells|addAllCells(io.resys.hdes.client.api.ast.AstDecision.AstDecisionCell) // {@link AstDecision.AstDecisionRow#getCells() cells} elements
   *    .build();
   * 
* @return A new ImmutableAstDecisionRow builder */ public static ImmutableAstDecisionRow.Builder builder() { return new ImmutableAstDecisionRow.Builder(); } /** * Builds instances of type {@link ImmutableAstDecisionRow ImmutableAstDecisionRow}. * 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 = "AstDecision.AstDecisionRow", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ID = 0x1L; private static final long INIT_BIT_ORDER = 0x2L; private long initBits = 0x3L; private @Nullable String id; private int order; private ImmutableList.Builder cells = ImmutableList.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code AstDecisionRow} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(AstDecision.AstDecisionRow instance) { Objects.requireNonNull(instance, "instance"); id(instance.getId()); order(instance.getOrder()); addAllCells(instance.getCells()); return this; } /** * Initializes the value for the {@link AstDecision.AstDecisionRow#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("id") public final Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Initializes the value for the {@link AstDecision.AstDecisionRow#getOrder() order} attribute. * @param order The value for order * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("order") public final Builder order(int order) { this.order = order; initBits &= ~INIT_BIT_ORDER; return this; } /** * Adds one element to {@link AstDecision.AstDecisionRow#getCells() cells} list. * @param element A cells element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addCells(AstDecision.AstDecisionCell element) { this.cells.add(element); return this; } /** * Adds elements to {@link AstDecision.AstDecisionRow#getCells() cells} list. * @param elements An array of cells elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addCells(AstDecision.AstDecisionCell... elements) { this.cells.add(elements); return this; } /** * Sets or replaces all elements for {@link AstDecision.AstDecisionRow#getCells() cells} list. * @param elements An iterable of cells elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("cells") public final Builder cells(Iterable elements) { this.cells = ImmutableList.builder(); return addAllCells(elements); } /** * Adds elements to {@link AstDecision.AstDecisionRow#getCells() cells} list. * @param elements An iterable of cells elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllCells(Iterable elements) { this.cells.addAll(elements); return this; } /** * Builds a new {@link ImmutableAstDecisionRow ImmutableAstDecisionRow}. * @return An immutable instance of AstDecisionRow * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableAstDecisionRow build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableAstDecisionRow(id, order, cells.build()); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_ORDER) != 0) attributes.add("order"); return "Cannot build AstDecisionRow, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy