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

com.hubspot.slack.client.models.response.im.ImOpenResponse Maven / Gradle / Ivy

There is a newer version: 1.16.7
Show newest version
package com.hubspot.slack.client.models.response.im;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.models.channel.ImChannel;
import com.hubspot.slack.client.models.response.*;
import com.hubspot.slack.client.models.response.SlackResponse;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
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 ImOpenResponseIF}.
 * 

* Use the builder to create immutable instances: * {@code ImOpenResponse.builder()}. */ @Generated(from = "ImOpenResponseIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ImOpenResponse implements ImOpenResponseIF { private final boolean ok; private final @Nullable ResponseMetadata responseMetadata; private final boolean noOp; private final boolean alreadyOpen; private final @Nullable ImChannel channel; private ImOpenResponse(ImOpenResponse.Builder builder) { this.ok = builder.ok; this.responseMetadata = builder.responseMetadata; this.channel = builder.channel; if (builder.noOpIsSet()) { initShim.setNoOp(builder.noOp); } if (builder.alreadyOpenIsSet()) { initShim.setAlreadyOpen(builder.alreadyOpen); } this.noOp = initShim.isNoOp(); this.alreadyOpen = initShim.isAlreadyOpen(); this.initShim = null; } private ImOpenResponse( boolean ok, @Nullable ResponseMetadata responseMetadata, boolean noOp, boolean alreadyOpen, @Nullable ImChannel channel) { this.ok = ok; this.responseMetadata = responseMetadata; this.noOp = noOp; this.alreadyOpen = alreadyOpen; this.channel = channel; this.initShim = null; } private static final byte STAGE_INITIALIZING = -1; private static final byte STAGE_UNINITIALIZED = 0; private static final byte STAGE_INITIALIZED = 1; private transient volatile InitShim initShim = new InitShim(); @Generated(from = "ImOpenResponseIF", generator = "Immutables") private final class InitShim { private byte noOpBuildStage = STAGE_UNINITIALIZED; private boolean noOp; boolean isNoOp() { if (noOpBuildStage == STAGE_INITIALIZING) throw new InvalidImmutableStateException(formatInitCycleMessage()); if (noOpBuildStage == STAGE_UNINITIALIZED) { noOpBuildStage = STAGE_INITIALIZING; this.noOp = isNoOpInitialize(); noOpBuildStage = STAGE_INITIALIZED; } return this.noOp; } void setNoOp(boolean noOp) { this.noOp = noOp; noOpBuildStage = STAGE_INITIALIZED; } private byte alreadyOpenBuildStage = STAGE_UNINITIALIZED; private boolean alreadyOpen; boolean isAlreadyOpen() { if (alreadyOpenBuildStage == STAGE_INITIALIZING) throw new InvalidImmutableStateException(formatInitCycleMessage()); if (alreadyOpenBuildStage == STAGE_UNINITIALIZED) { alreadyOpenBuildStage = STAGE_INITIALIZING; this.alreadyOpen = isAlreadyOpenInitialize(); alreadyOpenBuildStage = STAGE_INITIALIZED; } return this.alreadyOpen; } void setAlreadyOpen(boolean alreadyOpen) { this.alreadyOpen = alreadyOpen; alreadyOpenBuildStage = STAGE_INITIALIZED; } private String formatInitCycleMessage() { List attributes = new ArrayList<>(); if (noOpBuildStage == STAGE_INITIALIZING) attributes.add("noOp"); if (alreadyOpenBuildStage == STAGE_INITIALIZING) attributes.add("alreadyOpen"); return "Cannot build ImOpenResponse, attribute initializers form cycle " + attributes; } } private boolean isNoOpInitialize() { return ImOpenResponseIF.super.isNoOp(); } private boolean isAlreadyOpenInitialize() { return ImOpenResponseIF.super.isAlreadyOpen(); } /** * @return The value of the {@code ok} attribute */ @JsonProperty @Override public boolean isOk() { return ok; } /** * @return The value of the {@code responseMetadata} attribute */ @JsonProperty("response_metadata") @Override public Optional getResponseMetadata() { return Optional.ofNullable(responseMetadata); } /** * @return The value of the {@code noOp} attribute */ @JsonProperty @Override public boolean isNoOp() { InitShim shim = this.initShim; return shim != null ? shim.isNoOp() : this.noOp; } /** * @return The value of the {@code alreadyOpen} attribute */ @JsonProperty @Override public boolean isAlreadyOpen() { InitShim shim = this.initShim; return shim != null ? shim.isAlreadyOpen() : this.alreadyOpen; } /** * @return The value of the {@code channel} attribute */ @JsonProperty @Override public Optional getChannel() { return Optional.ofNullable(channel); } /** * Copy the current immutable object by setting a value for the {@link ImOpenResponseIF#isOk() ok} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for ok * @return A modified copy of the {@code this} object */ public final ImOpenResponse withOk(boolean value) { if (this.ok == value) return this; return new ImOpenResponse(value, this.responseMetadata, this.noOp, this.alreadyOpen, this.channel); } /** * Copy the current immutable object by setting a present value for the optional {@link ImOpenResponseIF#getResponseMetadata() responseMetadata} attribute. * @param value The value for responseMetadata, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ImOpenResponse withResponseMetadata(@Nullable ResponseMetadata value) { @Nullable ResponseMetadata newValue = value; if (this.responseMetadata == newValue) return this; return new ImOpenResponse(this.ok, newValue, this.noOp, this.alreadyOpen, this.channel); } /** * Copy the current immutable object by setting an optional value for the {@link ImOpenResponseIF#getResponseMetadata() responseMetadata} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for responseMetadata * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final ImOpenResponse withResponseMetadata(Optional optional) { @Nullable ResponseMetadata value = optional.orElse(null); if (this.responseMetadata == value) return this; return new ImOpenResponse(this.ok, value, this.noOp, this.alreadyOpen, this.channel); } /** * Copy the current immutable object by setting a value for the {@link ImOpenResponseIF#isNoOp() noOp} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for noOp * @return A modified copy of the {@code this} object */ public final ImOpenResponse withNoOp(boolean value) { if (this.noOp == value) return this; return new ImOpenResponse(this.ok, this.responseMetadata, value, this.alreadyOpen, this.channel); } /** * Copy the current immutable object by setting a value for the {@link ImOpenResponseIF#isAlreadyOpen() alreadyOpen} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for alreadyOpen * @return A modified copy of the {@code this} object */ public final ImOpenResponse withAlreadyOpen(boolean value) { if (this.alreadyOpen == value) return this; return new ImOpenResponse(this.ok, this.responseMetadata, this.noOp, value, this.channel); } /** * Copy the current immutable object by setting a present value for the optional {@link ImOpenResponseIF#getChannel() channel} attribute. * @param value The value for channel, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ImOpenResponse withChannel(@Nullable ImChannel value) { @Nullable ImChannel newValue = value; if (this.channel == newValue) return this; return new ImOpenResponse(this.ok, this.responseMetadata, this.noOp, this.alreadyOpen, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link ImOpenResponseIF#getChannel() channel} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for channel * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final ImOpenResponse withChannel(Optional optional) { @Nullable ImChannel value = optional.orElse(null); if (this.channel == value) return this; return new ImOpenResponse(this.ok, this.responseMetadata, this.noOp, this.alreadyOpen, value); } /** * This instance is equal to all instances of {@code ImOpenResponse} 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 ImOpenResponse && equalTo(0, (ImOpenResponse) another); } private boolean equalTo(int synthetic, ImOpenResponse another) { return ok == another.ok && Objects.equals(responseMetadata, another.responseMetadata) && noOp == another.noOp && alreadyOpen == another.alreadyOpen && Objects.equals(channel, another.channel); } /** * Computes a hash code from attributes: {@code ok}, {@code responseMetadata}, {@code noOp}, {@code alreadyOpen}, {@code channel}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Boolean.hashCode(ok); h += (h << 5) + Objects.hashCode(responseMetadata); h += (h << 5) + Boolean.hashCode(noOp); h += (h << 5) + Boolean.hashCode(alreadyOpen); h += (h << 5) + Objects.hashCode(channel); return h; } /** * Prints the immutable value {@code ImOpenResponse} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ImOpenResponse{"); builder.append("ok=").append(ok); if (responseMetadata != null) { builder.append(", "); builder.append("responseMetadata=").append(responseMetadata); } builder.append(", "); builder.append("noOp=").append(noOp); builder.append(", "); builder.append("alreadyOpen=").append(alreadyOpen); if (channel != null) { builder.append(", "); builder.append("channel=").append(channel); } return builder.append("}").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 = "ImOpenResponseIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ImOpenResponseIF { boolean ok; boolean okIsSet; @Nullable Optional responseMetadata = Optional.empty(); boolean noOp; boolean noOpIsSet; boolean alreadyOpen; boolean alreadyOpenIsSet; @Nullable Optional channel = Optional.empty(); @JsonProperty public void setOk(boolean ok) { this.ok = ok; this.okIsSet = true; } @JsonProperty("response_metadata") public void setResponseMetadata(Optional responseMetadata) { this.responseMetadata = responseMetadata; } @JsonProperty public void setNoOp(boolean noOp) { this.noOp = noOp; this.noOpIsSet = true; } @JsonProperty public void setAlreadyOpen(boolean alreadyOpen) { this.alreadyOpen = alreadyOpen; this.alreadyOpenIsSet = true; } @JsonProperty public void setChannel(Optional channel) { this.channel = channel; } @Override public boolean isOk() { throw new UnsupportedOperationException(); } @Override public Optional getResponseMetadata() { throw new UnsupportedOperationException(); } @Override public boolean isNoOp() { throw new UnsupportedOperationException(); } @Override public boolean isAlreadyOpen() { throw new UnsupportedOperationException(); } @Override public Optional getChannel() { 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 ImOpenResponse fromJson(Json json) { ImOpenResponse.Builder builder = ImOpenResponse.builder(); if (json.okIsSet) { builder.setOk(json.ok); } if (json.responseMetadata != null) { builder.setResponseMetadata(json.responseMetadata); } if (json.noOpIsSet) { builder.setNoOp(json.noOp); } if (json.alreadyOpenIsSet) { builder.setAlreadyOpen(json.alreadyOpen); } if (json.channel != null) { builder.setChannel(json.channel); } return builder.build(); } /** * Creates an immutable copy of a {@link ImOpenResponseIF} 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 ImOpenResponse instance */ public static ImOpenResponse copyOf(ImOpenResponseIF instance) { if (instance instanceof ImOpenResponse) { return (ImOpenResponse) instance; } return ImOpenResponse.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImOpenResponse ImOpenResponse}. *

   * ImOpenResponse.builder()
   *    .setOk(boolean) // required {@link ImOpenResponseIF#isOk() ok}
   *    .setResponseMetadata(ResponseMetadata) // optional {@link ImOpenResponseIF#getResponseMetadata() responseMetadata}
   *    .setNoOp(boolean) // optional {@link ImOpenResponseIF#isNoOp() noOp}
   *    .setAlreadyOpen(boolean) // optional {@link ImOpenResponseIF#isAlreadyOpen() alreadyOpen}
   *    .setChannel(com.hubspot.slack.client.models.channel.ImChannel) // optional {@link ImOpenResponseIF#getChannel() channel}
   *    .build();
   * 
* @return A new ImOpenResponse builder */ public static ImOpenResponse.Builder builder() { return new ImOpenResponse.Builder(); } /** * Builds instances of type {@link ImOpenResponse ImOpenResponse}. * 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 = "ImOpenResponseIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_OK = 0x1L; private static final long OPT_BIT_NO_OP = 0x1L; private static final long OPT_BIT_ALREADY_OPEN = 0x2L; private long initBits = 0x1L; private long optBits; private boolean ok; private @Nullable ResponseMetadata responseMetadata; private boolean noOp; private boolean alreadyOpen; private @Nullable ImChannel channel; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.response.SlackResponse} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(SlackResponse 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.response.im.ImOpenResponseIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ImOpenResponseIF 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 SlackResponse) { SlackResponse instance = (SlackResponse) object; if ((bits & 0x2L) == 0) { this.setOk(instance.isOk()); bits |= 0x2L; } if ((bits & 0x1L) == 0) { Optional responseMetadataOptional = instance.getResponseMetadata(); if (responseMetadataOptional.isPresent()) { setResponseMetadata(responseMetadataOptional); } bits |= 0x1L; } } if (object instanceof ImOpenResponseIF) { ImOpenResponseIF instance = (ImOpenResponseIF) object; Optional channelOptional = instance.getChannel(); if (channelOptional.isPresent()) { setChannel(channelOptional); } this.setAlreadyOpen(instance.isAlreadyOpen()); this.setNoOp(instance.isNoOp()); if ((bits & 0x1L) == 0) { Optional responseMetadataOptional = instance.getResponseMetadata(); if (responseMetadataOptional.isPresent()) { setResponseMetadata(responseMetadataOptional); } bits |= 0x1L; } if ((bits & 0x2L) == 0) { this.setOk(instance.isOk()); bits |= 0x2L; } } } /** * Initializes the value for the {@link ImOpenResponseIF#isOk() ok} attribute. * @param ok The value for ok * @return {@code this} builder for use in a chained invocation */ public final Builder setOk(boolean ok) { this.ok = ok; initBits &= ~INIT_BIT_OK; return this; } /** * Initializes the optional value {@link ImOpenResponseIF#getResponseMetadata() responseMetadata} to responseMetadata. * @param responseMetadata The value for responseMetadata, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setResponseMetadata(@Nullable ResponseMetadata responseMetadata) { this.responseMetadata = responseMetadata; return this; } /** * Initializes the optional value {@link ImOpenResponseIF#getResponseMetadata() responseMetadata} to responseMetadata. * @param responseMetadata The value for responseMetadata * @return {@code this} builder for use in a chained invocation */ public final Builder setResponseMetadata(Optional responseMetadata) { this.responseMetadata = responseMetadata.orElse(null); return this; } /** * Initializes the value for the {@link ImOpenResponseIF#isNoOp() noOp} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ImOpenResponseIF#isNoOp() noOp}. * @param noOp The value for noOp * @return {@code this} builder for use in a chained invocation */ public final Builder setNoOp(boolean noOp) { this.noOp = noOp; optBits |= OPT_BIT_NO_OP; return this; } /** * Initializes the value for the {@link ImOpenResponseIF#isAlreadyOpen() alreadyOpen} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ImOpenResponseIF#isAlreadyOpen() alreadyOpen}. * @param alreadyOpen The value for alreadyOpen * @return {@code this} builder for use in a chained invocation */ public final Builder setAlreadyOpen(boolean alreadyOpen) { this.alreadyOpen = alreadyOpen; optBits |= OPT_BIT_ALREADY_OPEN; return this; } /** * Initializes the optional value {@link ImOpenResponseIF#getChannel() channel} to channel. * @param channel The value for channel, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setChannel(@Nullable ImChannel channel) { this.channel = channel; return this; } /** * Initializes the optional value {@link ImOpenResponseIF#getChannel() channel} to channel. * @param channel The value for channel * @return {@code this} builder for use in a chained invocation */ public final Builder setChannel(Optional channel) { this.channel = channel.orElse(null); return this; } /** * Builds a new {@link ImOpenResponse ImOpenResponse}. * @return An immutable instance of ImOpenResponse * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ImOpenResponse build() { checkRequiredAttributes(); return new ImOpenResponse(this); } private boolean noOpIsSet() { return (optBits & OPT_BIT_NO_OP) != 0; } private boolean alreadyOpenIsSet() { return (optBits & OPT_BIT_ALREADY_OPEN) != 0; } private boolean okIsSet() { return (initBits & INIT_BIT_OK) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!okIsSet()) attributes.add("ok"); return "Cannot build ImOpenResponse, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy