
com.hubspot.slack.client.models.response.chat.ChatScheduleMessageResponse Maven / Gradle / Ivy
package com.hubspot.slack.client.models.response.chat;
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.response.*;
import com.hubspot.slack.client.models.response.SlackResponse;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
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 ChatScheduleMessageResponseIF}.
*
* Use the builder to create immutable instances:
* {@code ChatScheduleMessageResponse.builder()}.
*/
@Generated(from = "ChatScheduleMessageResponseIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class ChatScheduleMessageResponse
implements ChatScheduleMessageResponseIF {
private final boolean ok;
private final @Nullable ResponseMetadata responseMetadata;
private final String channel;
private final String scheduledMessageId;
private final String postAt;
private final Map message;
private ChatScheduleMessageResponse(
boolean ok,
@Nullable ResponseMetadata responseMetadata,
String channel,
String scheduledMessageId,
String postAt,
Map message) {
this.ok = ok;
this.responseMetadata = responseMetadata;
this.channel = channel;
this.scheduledMessageId = scheduledMessageId;
this.postAt = postAt;
this.message = message;
}
/**
* @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 channel} attribute
*/
@JsonProperty
@Override
public String getChannel() {
return channel;
}
/**
* @return The value of the {@code scheduledMessageId} attribute
*/
@JsonProperty
@Override
public String getScheduledMessageId() {
return scheduledMessageId;
}
/**
* @return The value of the {@code postAt} attribute
*/
@JsonProperty
@Override
public String getPostAt() {
return postAt;
}
/**
* @return The value of the {@code message} attribute
*/
@JsonProperty
@Override
public Map getMessage() {
return message;
}
/**
* Copy the current immutable object by setting a value for the {@link ChatScheduleMessageResponseIF#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 ChatScheduleMessageResponse withOk(boolean value) {
if (this.ok == value) return this;
return new ChatScheduleMessageResponse(value, this.responseMetadata, this.channel, this.scheduledMessageId, this.postAt, this.message);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ChatScheduleMessageResponseIF#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 ChatScheduleMessageResponse withResponseMetadata(@Nullable ResponseMetadata value) {
@Nullable ResponseMetadata newValue = value;
if (this.responseMetadata == newValue) return this;
return new ChatScheduleMessageResponse(this.ok, newValue, this.channel, this.scheduledMessageId, this.postAt, this.message);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ChatScheduleMessageResponseIF#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 ChatScheduleMessageResponse withResponseMetadata(Optional extends ResponseMetadata> optional) {
@Nullable ResponseMetadata value = optional.orElse(null);
if (this.responseMetadata == value) return this;
return new ChatScheduleMessageResponse(this.ok, value, this.channel, this.scheduledMessageId, this.postAt, this.message);
}
/**
* Copy the current immutable object by setting a value for the {@link ChatScheduleMessageResponseIF#getChannel() channel} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for channel
* @return A modified copy of the {@code this} object
*/
public final ChatScheduleMessageResponse withChannel(String value) {
String newValue = Objects.requireNonNull(value, "channel");
if (this.channel.equals(newValue)) return this;
return new ChatScheduleMessageResponse(this.ok, this.responseMetadata, newValue, this.scheduledMessageId, this.postAt, this.message);
}
/**
* Copy the current immutable object by setting a value for the {@link ChatScheduleMessageResponseIF#getScheduledMessageId() scheduledMessageId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for scheduledMessageId
* @return A modified copy of the {@code this} object
*/
public final ChatScheduleMessageResponse withScheduledMessageId(String value) {
String newValue = Objects.requireNonNull(value, "scheduledMessageId");
if (this.scheduledMessageId.equals(newValue)) return this;
return new ChatScheduleMessageResponse(this.ok, this.responseMetadata, this.channel, newValue, this.postAt, this.message);
}
/**
* Copy the current immutable object by setting a value for the {@link ChatScheduleMessageResponseIF#getPostAt() postAt} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for postAt
* @return A modified copy of the {@code this} object
*/
public final ChatScheduleMessageResponse withPostAt(String value) {
String newValue = Objects.requireNonNull(value, "postAt");
if (this.postAt.equals(newValue)) return this;
return new ChatScheduleMessageResponse(this.ok, this.responseMetadata, this.channel, this.scheduledMessageId, newValue, this.message);
}
/**
* Copy the current immutable object by replacing the {@link ChatScheduleMessageResponseIF#getMessage() message} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the message map
* @return A modified copy of {@code this} object
*/
public final ChatScheduleMessageResponse withMessage(Map entries) {
if (this.message == entries) return this;
Map newValue = createUnmodifiableMap(true, false, entries);
return new ChatScheduleMessageResponse(this.ok, this.responseMetadata, this.channel, this.scheduledMessageId, this.postAt, newValue);
}
/**
* This instance is equal to all instances of {@code ChatScheduleMessageResponse} 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 ChatScheduleMessageResponse
&& equalTo(0, (ChatScheduleMessageResponse) another);
}
private boolean equalTo(int synthetic, ChatScheduleMessageResponse another) {
return ok == another.ok
&& Objects.equals(responseMetadata, another.responseMetadata)
&& channel.equals(another.channel)
&& scheduledMessageId.equals(another.scheduledMessageId)
&& postAt.equals(another.postAt)
&& message.equals(another.message);
}
/**
* Computes a hash code from attributes: {@code ok}, {@code responseMetadata}, {@code channel}, {@code scheduledMessageId}, {@code postAt}, {@code message}.
* @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) + channel.hashCode();
h += (h << 5) + scheduledMessageId.hashCode();
h += (h << 5) + postAt.hashCode();
h += (h << 5) + message.hashCode();
return h;
}
/**
* Prints the immutable value {@code ChatScheduleMessageResponse} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("ChatScheduleMessageResponse{");
builder.append("ok=").append(ok);
if (responseMetadata != null) {
builder.append(", ");
builder.append("responseMetadata=").append(responseMetadata);
}
builder.append(", ");
builder.append("channel=").append(channel);
builder.append(", ");
builder.append("scheduledMessageId=").append(scheduledMessageId);
builder.append(", ");
builder.append("postAt=").append(postAt);
builder.append(", ");
builder.append("message=").append(message);
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 = "ChatScheduleMessageResponseIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json
implements ChatScheduleMessageResponseIF {
boolean ok;
boolean okIsSet;
@Nullable Optional responseMetadata = Optional.empty();
@Nullable String channel;
@Nullable String scheduledMessageId;
@Nullable String postAt;
@Nullable Map message = Collections.emptyMap();
@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 setChannel(String channel) {
this.channel = channel;
}
@JsonProperty
public void setScheduledMessageId(String scheduledMessageId) {
this.scheduledMessageId = scheduledMessageId;
}
@JsonProperty
public void setPostAt(String postAt) {
this.postAt = postAt;
}
@JsonProperty
public void setMessage(Map message) {
this.message = message;
}
@Override
public boolean isOk() { throw new UnsupportedOperationException(); }
@Override
public Optional getResponseMetadata() { throw new UnsupportedOperationException(); }
@Override
public String getChannel() { throw new UnsupportedOperationException(); }
@Override
public String getScheduledMessageId() { throw new UnsupportedOperationException(); }
@Override
public String getPostAt() { throw new UnsupportedOperationException(); }
@Override
public Map getMessage() { 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 ChatScheduleMessageResponse fromJson(Json json) {
ChatScheduleMessageResponse.Builder builder = ChatScheduleMessageResponse.builder();
if (json.okIsSet) {
builder.setOk(json.ok);
}
if (json.responseMetadata != null) {
builder.setResponseMetadata(json.responseMetadata);
}
if (json.channel != null) {
builder.setChannel(json.channel);
}
if (json.scheduledMessageId != null) {
builder.setScheduledMessageId(json.scheduledMessageId);
}
if (json.postAt != null) {
builder.setPostAt(json.postAt);
}
if (json.message != null) {
builder.putAllMessage(json.message);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link ChatScheduleMessageResponseIF} 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 ChatScheduleMessageResponse instance
*/
public static ChatScheduleMessageResponse copyOf(ChatScheduleMessageResponseIF instance) {
if (instance instanceof ChatScheduleMessageResponse) {
return (ChatScheduleMessageResponse) instance;
}
return ChatScheduleMessageResponse.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ChatScheduleMessageResponse ChatScheduleMessageResponse}.
*
* ChatScheduleMessageResponse.builder()
* .setOk(boolean) // required {@link ChatScheduleMessageResponseIF#isOk() ok}
* .setResponseMetadata(ResponseMetadata) // optional {@link ChatScheduleMessageResponseIF#getResponseMetadata() responseMetadata}
* .setChannel(String) // required {@link ChatScheduleMessageResponseIF#getChannel() channel}
* .setScheduledMessageId(String) // required {@link ChatScheduleMessageResponseIF#getScheduledMessageId() scheduledMessageId}
* .setPostAt(String) // required {@link ChatScheduleMessageResponseIF#getPostAt() postAt}
* .putMessage|putAllMessage(String => Object) // {@link ChatScheduleMessageResponseIF#getMessage() message} mappings
* .build();
*
* @return A new ChatScheduleMessageResponse builder
*/
public static ChatScheduleMessageResponse.Builder builder() {
return new ChatScheduleMessageResponse.Builder();
}
/**
* Builds instances of type {@link ChatScheduleMessageResponse ChatScheduleMessageResponse}.
* 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 = "ChatScheduleMessageResponseIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_OK = 0x1L;
private static final long INIT_BIT_CHANNEL = 0x2L;
private static final long INIT_BIT_SCHEDULED_MESSAGE_ID = 0x4L;
private static final long INIT_BIT_POST_AT = 0x8L;
private long initBits = 0xfL;
private boolean ok;
private @Nullable ResponseMetadata responseMetadata;
private @Nullable String channel;
private @Nullable String scheduledMessageId;
private @Nullable String postAt;
private Map message = new LinkedHashMap();
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.chat.ChatScheduleMessageResponseIF} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(ChatScheduleMessageResponseIF 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 ChatScheduleMessageResponseIF) {
ChatScheduleMessageResponseIF instance = (ChatScheduleMessageResponseIF) object;
this.setChannel(instance.getChannel());
this.setPostAt(instance.getPostAt());
if ((bits & 0x1L) == 0) {
Optional responseMetadataOptional = instance.getResponseMetadata();
if (responseMetadataOptional.isPresent()) {
setResponseMetadata(responseMetadataOptional);
}
bits |= 0x1L;
}
putAllMessage(instance.getMessage());
if ((bits & 0x2L) == 0) {
this.setOk(instance.isOk());
bits |= 0x2L;
}
this.setScheduledMessageId(instance.getScheduledMessageId());
}
}
/**
* Initializes the value for the {@link ChatScheduleMessageResponseIF#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 ChatScheduleMessageResponseIF#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 ChatScheduleMessageResponseIF#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 extends ResponseMetadata> responseMetadata) {
this.responseMetadata = responseMetadata.orElse(null);
return this;
}
/**
* Initializes the value for the {@link ChatScheduleMessageResponseIF#getChannel() channel} attribute.
* @param channel The value for channel
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setChannel(String channel) {
this.channel = Objects.requireNonNull(channel, "channel");
initBits &= ~INIT_BIT_CHANNEL;
return this;
}
/**
* Initializes the value for the {@link ChatScheduleMessageResponseIF#getScheduledMessageId() scheduledMessageId} attribute.
* @param scheduledMessageId The value for scheduledMessageId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setScheduledMessageId(String scheduledMessageId) {
this.scheduledMessageId = Objects.requireNonNull(scheduledMessageId, "scheduledMessageId");
initBits &= ~INIT_BIT_SCHEDULED_MESSAGE_ID;
return this;
}
/**
* Initializes the value for the {@link ChatScheduleMessageResponseIF#getPostAt() postAt} attribute.
* @param postAt The value for postAt
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setPostAt(String postAt) {
this.postAt = Objects.requireNonNull(postAt, "postAt");
initBits &= ~INIT_BIT_POST_AT;
return this;
}
/**
* Put one entry to the {@link ChatScheduleMessageResponseIF#getMessage() message} map.
* @param key The key in the message map
* @param value The associated value in the message map
* @return {@code this} builder for use in a chained invocation
*/
public final Builder putMessage(String key, Object value) {
this.message.put(
Objects.requireNonNull(key, "message key"),
Objects.requireNonNull(value, value == null ? "message value for key: " + key : null));
return this;
}
/**
* Put one entry to the {@link ChatScheduleMessageResponseIF#getMessage() message} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
public final Builder putMessage(Map.Entry entry) {
String k = entry.getKey();
Object v = entry.getValue();
this.message.put(
Objects.requireNonNull(k, "message key"),
Objects.requireNonNull(v, v == null ? "message value for key: " + k : null));
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link ChatScheduleMessageResponseIF#getMessage() message} map. Nulls are not permitted
* @param entries The entries that will be added to the message map
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setMessage(Map entries) {
this.message.clear();
return putAllMessage(entries);
}
/**
* Put all mappings from the specified map as entries to {@link ChatScheduleMessageResponseIF#getMessage() message} map. Nulls are not permitted
* @param entries The entries that will be added to the message map
* @return {@code this} builder for use in a chained invocation
*/
public final Builder putAllMessage(Map entries) {
for (Map.Entry e : entries.entrySet()) {
String k = e.getKey();
Object v = e.getValue();
this.message.put(
Objects.requireNonNull(k, "message key"),
Objects.requireNonNull(v, v == null ? "message value for key: " + k : null));
}
return this;
}
/**
* Builds a new {@link ChatScheduleMessageResponse ChatScheduleMessageResponse}.
* @return An immutable instance of ChatScheduleMessageResponse
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public ChatScheduleMessageResponse build() {
checkRequiredAttributes();
return new ChatScheduleMessageResponse(
ok,
responseMetadata,
channel,
scheduledMessageId,
postAt,
createUnmodifiableMap(false, false, message));
}
private boolean okIsSet() {
return (initBits & INIT_BIT_OK) == 0;
}
private boolean channelIsSet() {
return (initBits & INIT_BIT_CHANNEL) == 0;
}
private boolean scheduledMessageIdIsSet() {
return (initBits & INIT_BIT_SCHEDULED_MESSAGE_ID) == 0;
}
private boolean postAtIsSet() {
return (initBits & INIT_BIT_POST_AT) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!okIsSet()) attributes.add("ok");
if (!channelIsSet()) attributes.add("channel");
if (!scheduledMessageIdIsSet()) attributes.add("scheduledMessageId");
if (!postAtIsSet()) attributes.add("postAt");
return "Cannot build ChatScheduleMessageResponse, some of required attributes are not set " + attributes;
}
}
private static Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, Map extends K, ? extends V> map) {
switch (map.size()) {
case 0: return Collections.emptyMap();
case 1: {
Map.Entry extends K, ? extends V> e = map.entrySet().iterator().next();
K k = e.getKey();
V v = e.getValue();
if (checkNulls) {
Objects.requireNonNull(k, "key");
Objects.requireNonNull(v, v == null ? "value for key: " + k : null);
}
if (skipNulls && (k == null || v == null)) {
return Collections.emptyMap();
}
return Collections.singletonMap(k, v);
}
default: {
Map linkedMap = new LinkedHashMap<>(map.size() * 4 / 3 + 1);
if (skipNulls || checkNulls) {
for (Map.Entry extends K, ? extends V> e : map.entrySet()) {
K k = e.getKey();
V v = e.getValue();
if (skipNulls) {
if (k == null || v == null) continue;
} else if (checkNulls) {
Objects.requireNonNull(k, "key");
Objects.requireNonNull(v, v == null ? "value for key: " + k : null);
}
linkedMap.put(k, v);
}
} else {
linkedMap.putAll(map);
}
return Collections.unmodifiableMap(linkedMap);
}
}
}
}