
com.hubspot.slack.client.models.interaction.MessageContainer 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 MessageContainerIF}.
*
* Use the builder to create immutable instances:
* {@code MessageContainer.builder()}.
*/
@Generated(from = "MessageContainerIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class MessageContainer implements MessageContainerIF {
private final ContainerType type;
private final String messageTs;
private final String channelId;
private final boolean ephemeral;
private MessageContainer(
ContainerType type,
String messageTs,
String channelId,
boolean ephemeral) {
this.type = type;
this.messageTs = messageTs;
this.channelId = channelId;
this.ephemeral = ephemeral;
}
/**
* @return The value of the {@code type} attribute
*/
@JsonProperty
@Override
public ContainerType getType() {
return type;
}
/**
* @return The value of the {@code messageTs} attribute
*/
@JsonProperty
@Override
public String getMessageTs() {
return messageTs;
}
/**
* @return The value of the {@code channelId} attribute
*/
@JsonProperty
@Override
public String getChannelId() {
return channelId;
}
/**
* @return The value of the {@code ephemeral} attribute
*/
@JsonProperty("is_ephemeral")
@Override
public boolean isEphemeral() {
return ephemeral;
}
/**
* Copy the current immutable object by setting a value for the {@link MessageContainerIF#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 MessageContainer withType(ContainerType value) {
ContainerType newValue = Objects.requireNonNull(value, "type");
if (this.type == newValue) return this;
return new MessageContainer(newValue, this.messageTs, this.channelId, this.ephemeral);
}
/**
* Copy the current immutable object by setting a value for the {@link MessageContainerIF#getMessageTs() messageTs} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for messageTs
* @return A modified copy of the {@code this} object
*/
public final MessageContainer withMessageTs(String value) {
String newValue = Objects.requireNonNull(value, "messageTs");
if (this.messageTs.equals(newValue)) return this;
return new MessageContainer(this.type, newValue, this.channelId, this.ephemeral);
}
/**
* Copy the current immutable object by setting a value for the {@link MessageContainerIF#getChannelId() channelId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for channelId
* @return A modified copy of the {@code this} object
*/
public final MessageContainer withChannelId(String value) {
String newValue = Objects.requireNonNull(value, "channelId");
if (this.channelId.equals(newValue)) return this;
return new MessageContainer(this.type, this.messageTs, newValue, this.ephemeral);
}
/**
* Copy the current immutable object by setting a value for the {@link MessageContainerIF#isEphemeral() ephemeral} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for ephemeral
* @return A modified copy of the {@code this} object
*/
public final MessageContainer withEphemeral(boolean value) {
if (this.ephemeral == value) return this;
return new MessageContainer(this.type, this.messageTs, this.channelId, value);
}
/**
* This instance is equal to all instances of {@code MessageContainer} 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 MessageContainer
&& equalTo(0, (MessageContainer) another);
}
private boolean equalTo(int synthetic, MessageContainer another) {
return type.equals(another.type)
&& messageTs.equals(another.messageTs)
&& channelId.equals(another.channelId)
&& ephemeral == another.ephemeral;
}
/**
* Computes a hash code from attributes: {@code type}, {@code messageTs}, {@code channelId}, {@code ephemeral}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + type.hashCode();
h += (h << 5) + messageTs.hashCode();
h += (h << 5) + channelId.hashCode();
h += (h << 5) + Boolean.hashCode(ephemeral);
return h;
}
/**
* Prints the immutable value {@code MessageContainer} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "MessageContainer{"
+ "type=" + type
+ ", messageTs=" + messageTs
+ ", channelId=" + channelId
+ ", ephemeral=" + ephemeral
+ "}";
}
/**
* 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 = "MessageContainerIF", generator = "Immutables")
@Deprecated
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements MessageContainerIF {
@Nullable ContainerType type;
@Nullable String messageTs;
@Nullable String channelId;
boolean ephemeral;
boolean ephemeralIsSet;
@JsonProperty
public void setType(ContainerType type) {
this.type = type;
}
@JsonProperty
public void setMessageTs(String messageTs) {
this.messageTs = messageTs;
}
@JsonProperty
public void setChannelId(String channelId) {
this.channelId = channelId;
}
@JsonProperty("is_ephemeral")
public void setEphemeral(boolean ephemeral) {
this.ephemeral = ephemeral;
this.ephemeralIsSet = true;
}
@Override
public ContainerType getType() { throw new UnsupportedOperationException(); }
@Override
public String getMessageTs() { throw new UnsupportedOperationException(); }
@Override
public String getChannelId() { throw new UnsupportedOperationException(); }
@Override
public boolean isEphemeral() { 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 MessageContainer fromJson(Json json) {
MessageContainer.Builder builder = MessageContainer.builder();
if (json.type != null) {
builder.setType(json.type);
}
if (json.messageTs != null) {
builder.setMessageTs(json.messageTs);
}
if (json.channelId != null) {
builder.setChannelId(json.channelId);
}
if (json.ephemeralIsSet) {
builder.setEphemeral(json.ephemeral);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link MessageContainerIF} 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 MessageContainer instance
*/
public static MessageContainer copyOf(MessageContainerIF instance) {
if (instance instanceof MessageContainer) {
return (MessageContainer) instance;
}
return MessageContainer.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link MessageContainer MessageContainer}.
*
* MessageContainer.builder()
* .setType(com.hubspot.slack.client.models.interaction.ContainerType) // required {@link MessageContainerIF#getType() type}
* .setMessageTs(String) // required {@link MessageContainerIF#getMessageTs() messageTs}
* .setChannelId(String) // required {@link MessageContainerIF#getChannelId() channelId}
* .setEphemeral(boolean) // required {@link MessageContainerIF#isEphemeral() ephemeral}
* .build();
*
* @return A new MessageContainer builder
*/
public static MessageContainer.Builder builder() {
return new MessageContainer.Builder();
}
/**
* Builds instances of type {@link MessageContainer MessageContainer}.
* 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 = "MessageContainerIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_TYPE = 0x1L;
private static final long INIT_BIT_MESSAGE_TS = 0x2L;
private static final long INIT_BIT_CHANNEL_ID = 0x4L;
private static final long INIT_BIT_EPHEMERAL = 0x8L;
private long initBits = 0xfL;
private @Nullable ContainerType type;
private @Nullable String messageTs;
private @Nullable String channelId;
private boolean ephemeral;
private Builder() {
}
/**
* 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;
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.interaction.MessageContainerIF} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(MessageContainerIF 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 Container) {
Container instance = (Container) object;
if ((bits & 0x1L) == 0) {
this.setType(instance.getType());
bits |= 0x1L;
}
}
if (object instanceof MessageContainerIF) {
MessageContainerIF instance = (MessageContainerIF) object;
this.setEphemeral(instance.isEphemeral());
if ((bits & 0x1L) == 0) {
this.setType(instance.getType());
bits |= 0x1L;
}
this.setMessageTs(instance.getMessageTs());
this.setChannelId(instance.getChannelId());
}
}
/**
* Initializes the value for the {@link MessageContainerIF#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 MessageContainerIF#getMessageTs() messageTs} attribute.
* @param messageTs The value for messageTs
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setMessageTs(String messageTs) {
this.messageTs = Objects.requireNonNull(messageTs, "messageTs");
initBits &= ~INIT_BIT_MESSAGE_TS;
return this;
}
/**
* Initializes the value for the {@link MessageContainerIF#getChannelId() channelId} attribute.
* @param channelId The value for channelId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setChannelId(String channelId) {
this.channelId = Objects.requireNonNull(channelId, "channelId");
initBits &= ~INIT_BIT_CHANNEL_ID;
return this;
}
/**
* Initializes the value for the {@link MessageContainerIF#isEphemeral() ephemeral} attribute.
* @param ephemeral The value for ephemeral
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setEphemeral(boolean ephemeral) {
this.ephemeral = ephemeral;
initBits &= ~INIT_BIT_EPHEMERAL;
return this;
}
/**
* Builds a new {@link MessageContainer MessageContainer}.
* @return An immutable instance of MessageContainer
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public MessageContainer build() {
checkRequiredAttributes();
return new MessageContainer(type, messageTs, channelId, ephemeral);
}
private boolean typeIsSet() {
return (initBits & INIT_BIT_TYPE) == 0;
}
private boolean messageTsIsSet() {
return (initBits & INIT_BIT_MESSAGE_TS) == 0;
}
private boolean channelIdIsSet() {
return (initBits & INIT_BIT_CHANNEL_ID) == 0;
}
private boolean ephemeralIsSet() {
return (initBits & INIT_BIT_EPHEMERAL) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!typeIsSet()) attributes.add("type");
if (!messageTsIsSet()) attributes.add("messageTs");
if (!channelIdIsSet()) attributes.add("channelId");
if (!ephemeralIsSet()) attributes.add("ephemeral");
return "Cannot build MessageContainer, some of required attributes are not set " + attributes;
}
}
}