software.amazon.awssdk.services.chime.model.ChannelMessageSummary Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.chime.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Summary of the messages in a Channel.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ChannelMessageSummary implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField MESSAGE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("MessageId").getter(getter(ChannelMessageSummary::messageId)).setter(setter(Builder::messageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MessageId").build()).build();
private static final SdkField CONTENT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Content")
.getter(getter(ChannelMessageSummary::content)).setter(setter(Builder::content))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Content").build()).build();
private static final SdkField METADATA_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Metadata").getter(getter(ChannelMessageSummary::metadata)).setter(setter(Builder::metadata))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metadata").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(ChannelMessageSummary::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField CREATED_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedTimestamp").getter(getter(ChannelMessageSummary::createdTimestamp))
.setter(setter(Builder::createdTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTimestamp").build()).build();
private static final SdkField LAST_UPDATED_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastUpdatedTimestamp").getter(getter(ChannelMessageSummary::lastUpdatedTimestamp))
.setter(setter(Builder::lastUpdatedTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastUpdatedTimestamp").build())
.build();
private static final SdkField LAST_EDITED_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastEditedTimestamp").getter(getter(ChannelMessageSummary::lastEditedTimestamp))
.setter(setter(Builder::lastEditedTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastEditedTimestamp").build())
.build();
private static final SdkField SENDER_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Sender").getter(getter(ChannelMessageSummary::sender)).setter(setter(Builder::sender))
.constructor(Identity::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Sender").build()).build();
private static final SdkField REDACTED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("Redacted").getter(getter(ChannelMessageSummary::redacted)).setter(setter(Builder::redacted))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Redacted").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MESSAGE_ID_FIELD,
CONTENT_FIELD, METADATA_FIELD, TYPE_FIELD, CREATED_TIMESTAMP_FIELD, LAST_UPDATED_TIMESTAMP_FIELD,
LAST_EDITED_TIMESTAMP_FIELD, SENDER_FIELD, REDACTED_FIELD));
private static final long serialVersionUID = 1L;
private final String messageId;
private final String content;
private final String metadata;
private final String type;
private final Instant createdTimestamp;
private final Instant lastUpdatedTimestamp;
private final Instant lastEditedTimestamp;
private final Identity sender;
private final Boolean redacted;
private ChannelMessageSummary(BuilderImpl builder) {
this.messageId = builder.messageId;
this.content = builder.content;
this.metadata = builder.metadata;
this.type = builder.type;
this.createdTimestamp = builder.createdTimestamp;
this.lastUpdatedTimestamp = builder.lastUpdatedTimestamp;
this.lastEditedTimestamp = builder.lastEditedTimestamp;
this.sender = builder.sender;
this.redacted = builder.redacted;
}
/**
*
* The ID of the message.
*
*
* @return The ID of the message.
*/
public final String messageId() {
return messageId;
}
/**
*
* The content of the message.
*
*
* @return The content of the message.
*/
public final String content() {
return content;
}
/**
*
* The metadata of the message.
*
*
* @return The metadata of the message.
*/
public final String metadata() {
return metadata;
}
/**
*
* The type of message.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ChannelMessageType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of message.
* @see ChannelMessageType
*/
public final ChannelMessageType type() {
return ChannelMessageType.fromValue(type);
}
/**
*
* The type of message.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ChannelMessageType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of message.
* @see ChannelMessageType
*/
public final String typeAsString() {
return type;
}
/**
*
* The time at which the message summary was created.
*
*
* @return The time at which the message summary was created.
*/
public final Instant createdTimestamp() {
return createdTimestamp;
}
/**
*
* The time at which a message was last updated.
*
*
* @return The time at which a message was last updated.
*/
public final Instant lastUpdatedTimestamp() {
return lastUpdatedTimestamp;
}
/**
*
* The time at which a message was last edited.
*
*
* @return The time at which a message was last edited.
*/
public final Instant lastEditedTimestamp() {
return lastEditedTimestamp;
}
/**
*
* The message sender.
*
*
* @return The message sender.
*/
public final Identity sender() {
return sender;
}
/**
*
* Indicates whether a message was redacted.
*
*
* @return Indicates whether a message was redacted.
*/
public final Boolean redacted() {
return redacted;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(messageId());
hashCode = 31 * hashCode + Objects.hashCode(content());
hashCode = 31 * hashCode + Objects.hashCode(metadata());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(createdTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(lastEditedTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(sender());
hashCode = 31 * hashCode + Objects.hashCode(redacted());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ChannelMessageSummary)) {
return false;
}
ChannelMessageSummary other = (ChannelMessageSummary) obj;
return Objects.equals(messageId(), other.messageId()) && Objects.equals(content(), other.content())
&& Objects.equals(metadata(), other.metadata()) && Objects.equals(typeAsString(), other.typeAsString())
&& Objects.equals(createdTimestamp(), other.createdTimestamp())
&& Objects.equals(lastUpdatedTimestamp(), other.lastUpdatedTimestamp())
&& Objects.equals(lastEditedTimestamp(), other.lastEditedTimestamp()) && Objects.equals(sender(), other.sender())
&& Objects.equals(redacted(), other.redacted());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("ChannelMessageSummary").add("MessageId", messageId())
.add("Content", content() == null ? null : "*** Sensitive Data Redacted ***")
.add("Metadata", metadata() == null ? null : "*** Sensitive Data Redacted ***").add("Type", typeAsString())
.add("CreatedTimestamp", createdTimestamp()).add("LastUpdatedTimestamp", lastUpdatedTimestamp())
.add("LastEditedTimestamp", lastEditedTimestamp()).add("Sender", sender()).add("Redacted", redacted()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "MessageId":
return Optional.ofNullable(clazz.cast(messageId()));
case "Content":
return Optional.ofNullable(clazz.cast(content()));
case "Metadata":
return Optional.ofNullable(clazz.cast(metadata()));
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "CreatedTimestamp":
return Optional.ofNullable(clazz.cast(createdTimestamp()));
case "LastUpdatedTimestamp":
return Optional.ofNullable(clazz.cast(lastUpdatedTimestamp()));
case "LastEditedTimestamp":
return Optional.ofNullable(clazz.cast(lastEditedTimestamp()));
case "Sender":
return Optional.ofNullable(clazz.cast(sender()));
case "Redacted":
return Optional.ofNullable(clazz.cast(redacted()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function