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

com.hubspot.slack.client.models.interaction.ViewContainer Maven / Gradle / Ivy

package com.hubspot.slack.client.models.interaction;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
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 ViewContainerIF}.
 * 

* Use the builder to create immutable instances: * {@code ViewContainer.builder()}. */ @Generated(from = "ViewContainerIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ViewContainer implements ViewContainerIF { private final ContainerType type; private final String viewId; private ViewContainer(ContainerType type, String viewId) { this.type = type; this.viewId = viewId; } /** * @return The value of the {@code type} attribute */ @JsonProperty @Override public ContainerType getType() { return type; } /** * @return The value of the {@code viewId} attribute */ @JsonProperty @Override public String getViewId() { return viewId; } /** * Copy the current immutable object by setting a value for the {@link ViewContainerIF#getType() type} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final ViewContainer withType(ContainerType value) { ContainerType newValue = Objects.requireNonNull(value, "type"); if (this.type == newValue) return this; return new ViewContainer(newValue, this.viewId); } /** * Copy the current immutable object by setting a value for the {@link ViewContainerIF#getViewId() viewId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for viewId * @return A modified copy of the {@code this} object */ public final ViewContainer withViewId(String value) { String newValue = Objects.requireNonNull(value, "viewId"); if (this.viewId.equals(newValue)) return this; return new ViewContainer(this.type, newValue); } /** * This instance is equal to all instances of {@code ViewContainer} 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 ViewContainer && equalTo(0, (ViewContainer) another); } private boolean equalTo(int synthetic, ViewContainer another) { return type.equals(another.type) && viewId.equals(another.viewId); } /** * Computes a hash code from attributes: {@code type}, {@code viewId}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + type.hashCode(); h += (h << 5) + viewId.hashCode(); return h; } /** * Prints the immutable value {@code ViewContainer} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "ViewContainer{" + "type=" + type + ", viewId=" + viewId + "}"; } /** * 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 = "ViewContainerIF", generator = "Immutables") @Deprecated @JsonTypeInfo(use=JsonTypeInfo.Id.NONE) @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ViewContainerIF { @Nullable ContainerType type; @Nullable String viewId; @JsonProperty public void setType(ContainerType type) { this.type = type; } @JsonProperty public void setViewId(String viewId) { this.viewId = viewId; } @Override public ContainerType getType() { throw new UnsupportedOperationException(); } @Override public String getViewId() { 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 ViewContainer fromJson(Json json) { ViewContainer.Builder builder = ViewContainer.builder(); if (json.type != null) { builder.setType(json.type); } if (json.viewId != null) { builder.setViewId(json.viewId); } return builder.build(); } /** * Creates an immutable copy of a {@link ViewContainerIF} 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 ViewContainer instance */ public static ViewContainer copyOf(ViewContainerIF instance) { if (instance instanceof ViewContainer) { return (ViewContainer) instance; } return ViewContainer.builder() .from(instance) .build(); } /** * Creates a builder for {@link ViewContainer ViewContainer}. *

   * ViewContainer.builder()
   *    .setType(com.hubspot.slack.client.models.interaction.ContainerType) // required {@link ViewContainerIF#getType() type}
   *    .setViewId(String) // required {@link ViewContainerIF#getViewId() viewId}
   *    .build();
   * 
* @return A new ViewContainer builder */ public static ViewContainer.Builder builder() { return new ViewContainer.Builder(); } /** * Builds instances of type {@link ViewContainer ViewContainer}. * 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 = "ViewContainerIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_TYPE = 0x1L; private static final long INIT_BIT_VIEW_ID = 0x2L; private long initBits = 0x3L; private @Nullable ContainerType type; private @Nullable String viewId; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.interaction.ViewContainerIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ViewContainerIF instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.interaction.Container} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Container instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { long bits = 0; if (object instanceof ViewContainerIF) { ViewContainerIF instance = (ViewContainerIF) object; if ((bits & 0x1L) == 0) { this.setType(instance.getType()); bits |= 0x1L; } this.setViewId(instance.getViewId()); } if (object instanceof Container) { Container instance = (Container) object; if ((bits & 0x1L) == 0) { this.setType(instance.getType()); bits |= 0x1L; } } } /** * Initializes the value for the {@link ViewContainerIF#getType() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ public final Builder setType(ContainerType type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Initializes the value for the {@link ViewContainerIF#getViewId() viewId} attribute. * @param viewId The value for viewId * @return {@code this} builder for use in a chained invocation */ public final Builder setViewId(String viewId) { this.viewId = Objects.requireNonNull(viewId, "viewId"); initBits &= ~INIT_BIT_VIEW_ID; return this; } /** * Builds a new {@link ViewContainer ViewContainer}. * @return An immutable instance of ViewContainer * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ViewContainer build() { checkRequiredAttributes(); return new ViewContainer(type, viewId); } private boolean typeIsSet() { return (initBits & INIT_BIT_TYPE) == 0; } private boolean viewIdIsSet() { return (initBits & INIT_BIT_VIEW_ID) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!typeIsSet()) attributes.add("type"); if (!viewIdIsSet()) attributes.add("viewId"); return "Cannot build ViewContainer, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy