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

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 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 getter(Function g) { return obj -> g.apply((ChannelMessageSummary) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The ID of the message. *

* * @param messageId * The ID of the message. * @return Returns a reference to this object so that method calls can be chained together. */ Builder messageId(String messageId); /** *

* The content of the message. *

* * @param content * The content of the message. * @return Returns a reference to this object so that method calls can be chained together. */ Builder content(String content); /** *

* The metadata of the message. *

* * @param metadata * The metadata of the message. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metadata(String metadata); /** *

* The type of message. *

* * @param type * The type of message. * @see ChannelMessageType * @return Returns a reference to this object so that method calls can be chained together. * @see ChannelMessageType */ Builder type(String type); /** *

* The type of message. *

* * @param type * The type of message. * @see ChannelMessageType * @return Returns a reference to this object so that method calls can be chained together. * @see ChannelMessageType */ Builder type(ChannelMessageType type); /** *

* The time at which the message summary was created. *

* * @param createdTimestamp * The time at which the message summary was created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createdTimestamp(Instant createdTimestamp); /** *

* The time at which a message was last updated. *

* * @param lastUpdatedTimestamp * The time at which a message was last updated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastUpdatedTimestamp(Instant lastUpdatedTimestamp); /** *

* The time at which a message was last edited. *

* * @param lastEditedTimestamp * The time at which a message was last edited. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastEditedTimestamp(Instant lastEditedTimestamp); /** *

* The message sender. *

* * @param sender * The message sender. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sender(Identity sender); /** *

* The message sender. *

* This is a convenience method that creates an instance of the {@link Identity.Builder} avoiding the need to * create one manually via {@link Identity#builder()}. * *

* When the {@link Consumer} completes, {@link Identity.Builder#build()} is called immediately and its result is * passed to {@link #sender(Identity)}. * * @param sender * a consumer that will call methods on {@link Identity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #sender(Identity) */ default Builder sender(Consumer sender) { return sender(Identity.builder().applyMutation(sender).build()); } /** *

* Indicates whether a message was redacted. *

* * @param redacted * Indicates whether a message was redacted. * @return Returns a reference to this object so that method calls can be chained together. */ Builder redacted(Boolean redacted); } static final class BuilderImpl implements Builder { private String messageId; private String content; private String metadata; private String type; private Instant createdTimestamp; private Instant lastUpdatedTimestamp; private Instant lastEditedTimestamp; private Identity sender; private Boolean redacted; private BuilderImpl() { } private BuilderImpl(ChannelMessageSummary model) { messageId(model.messageId); content(model.content); metadata(model.metadata); type(model.type); createdTimestamp(model.createdTimestamp); lastUpdatedTimestamp(model.lastUpdatedTimestamp); lastEditedTimestamp(model.lastEditedTimestamp); sender(model.sender); redacted(model.redacted); } public final String getMessageId() { return messageId; } public final void setMessageId(String messageId) { this.messageId = messageId; } @Override public final Builder messageId(String messageId) { this.messageId = messageId; return this; } public final String getContent() { return content; } public final void setContent(String content) { this.content = content; } @Override public final Builder content(String content) { this.content = content; return this; } public final String getMetadata() { return metadata; } public final void setMetadata(String metadata) { this.metadata = metadata; } @Override public final Builder metadata(String metadata) { this.metadata = metadata; return this; } public final String getType() { return type; } public final void setType(String type) { this.type = type; } @Override public final Builder type(String type) { this.type = type; return this; } @Override public final Builder type(ChannelMessageType type) { this.type(type == null ? null : type.toString()); return this; } public final Instant getCreatedTimestamp() { return createdTimestamp; } public final void setCreatedTimestamp(Instant createdTimestamp) { this.createdTimestamp = createdTimestamp; } @Override public final Builder createdTimestamp(Instant createdTimestamp) { this.createdTimestamp = createdTimestamp; return this; } public final Instant getLastUpdatedTimestamp() { return lastUpdatedTimestamp; } public final void setLastUpdatedTimestamp(Instant lastUpdatedTimestamp) { this.lastUpdatedTimestamp = lastUpdatedTimestamp; } @Override public final Builder lastUpdatedTimestamp(Instant lastUpdatedTimestamp) { this.lastUpdatedTimestamp = lastUpdatedTimestamp; return this; } public final Instant getLastEditedTimestamp() { return lastEditedTimestamp; } public final void setLastEditedTimestamp(Instant lastEditedTimestamp) { this.lastEditedTimestamp = lastEditedTimestamp; } @Override public final Builder lastEditedTimestamp(Instant lastEditedTimestamp) { this.lastEditedTimestamp = lastEditedTimestamp; return this; } public final Identity.Builder getSender() { return sender != null ? sender.toBuilder() : null; } public final void setSender(Identity.BuilderImpl sender) { this.sender = sender != null ? sender.build() : null; } @Override public final Builder sender(Identity sender) { this.sender = sender; return this; } public final Boolean getRedacted() { return redacted; } public final void setRedacted(Boolean redacted) { this.redacted = redacted; } @Override public final Builder redacted(Boolean redacted) { this.redacted = redacted; return this; } @Override public ChannelMessageSummary build() { return new ChannelMessageSummary(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy