software.amazon.awssdk.services.chime.model.Channel 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;
/**
*
* The details of a channel.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Channel implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(Channel::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField CHANNEL_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ChannelArn").getter(getter(Channel::channelArn)).setter(setter(Builder::channelArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ChannelArn").build()).build();
private static final SdkField MODE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Mode")
.getter(getter(Channel::modeAsString)).setter(setter(Builder::mode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Mode").build()).build();
private static final SdkField PRIVACY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Privacy")
.getter(getter(Channel::privacyAsString)).setter(setter(Builder::privacy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Privacy").build()).build();
private static final SdkField METADATA_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Metadata").getter(getter(Channel::metadata)).setter(setter(Builder::metadata))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metadata").build()).build();
private static final SdkField CREATED_BY_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("CreatedBy").getter(getter(Channel::createdBy)).setter(setter(Builder::createdBy))
.constructor(Identity::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedBy").build()).build();
private static final SdkField CREATED_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedTimestamp").getter(getter(Channel::createdTimestamp)).setter(setter(Builder::createdTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTimestamp").build()).build();
private static final SdkField LAST_MESSAGE_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastMessageTimestamp").getter(getter(Channel::lastMessageTimestamp))
.setter(setter(Builder::lastMessageTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastMessageTimestamp").build())
.build();
private static final SdkField LAST_UPDATED_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastUpdatedTimestamp").getter(getter(Channel::lastUpdatedTimestamp))
.setter(setter(Builder::lastUpdatedTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastUpdatedTimestamp").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, CHANNEL_ARN_FIELD,
MODE_FIELD, PRIVACY_FIELD, METADATA_FIELD, CREATED_BY_FIELD, CREATED_TIMESTAMP_FIELD, LAST_MESSAGE_TIMESTAMP_FIELD,
LAST_UPDATED_TIMESTAMP_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String channelArn;
private final String mode;
private final String privacy;
private final String metadata;
private final Identity createdBy;
private final Instant createdTimestamp;
private final Instant lastMessageTimestamp;
private final Instant lastUpdatedTimestamp;
private Channel(BuilderImpl builder) {
this.name = builder.name;
this.channelArn = builder.channelArn;
this.mode = builder.mode;
this.privacy = builder.privacy;
this.metadata = builder.metadata;
this.createdBy = builder.createdBy;
this.createdTimestamp = builder.createdTimestamp;
this.lastMessageTimestamp = builder.lastMessageTimestamp;
this.lastUpdatedTimestamp = builder.lastUpdatedTimestamp;
}
/**
*
* The name of the channel.
*
*
* @return The name of the channel.
*/
public final String name() {
return name;
}
/**
*
* The ARN of the channel.
*
*
* @return The ARN of the channel.
*/
public final String channelArn() {
return channelArn;
}
/**
*
* The mode of the channel.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mode} will return
* {@link ChannelMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #modeAsString}.
*
*
* @return The mode of the channel.
* @see ChannelMode
*/
public final ChannelMode mode() {
return ChannelMode.fromValue(mode);
}
/**
*
* The mode of the channel.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mode} will return
* {@link ChannelMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #modeAsString}.
*
*
* @return The mode of the channel.
* @see ChannelMode
*/
public final String modeAsString() {
return mode;
}
/**
*
* The channel's privacy setting.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #privacy} will
* return {@link ChannelPrivacy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #privacyAsString}.
*
*
* @return The channel's privacy setting.
* @see ChannelPrivacy
*/
public final ChannelPrivacy privacy() {
return ChannelPrivacy.fromValue(privacy);
}
/**
*
* The channel's privacy setting.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #privacy} will
* return {@link ChannelPrivacy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #privacyAsString}.
*
*
* @return The channel's privacy setting.
* @see ChannelPrivacy
*/
public final String privacyAsString() {
return privacy;
}
/**
*
* The channel's metadata.
*
*
* @return The channel's metadata.
*/
public final String metadata() {
return metadata;
}
/**
*
* The AppInstanceUser who created the channel.
*
*
* @return The AppInstanceUser who created the channel.
*/
public final Identity createdBy() {
return createdBy;
}
/**
*
* The time at which the AppInstanceUser created the channel.
*
*
* @return The time at which the AppInstanceUser created the channel.
*/
public final Instant createdTimestamp() {
return createdTimestamp;
}
/**
*
* The time at which a member sent the last message in the channel.
*
*
* @return The time at which a member sent the last message in the channel.
*/
public final Instant lastMessageTimestamp() {
return lastMessageTimestamp;
}
/**
*
* The time at which a channel was last updated.
*
*
* @return The time at which a channel was last updated.
*/
public final Instant lastUpdatedTimestamp() {
return lastUpdatedTimestamp;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(channelArn());
hashCode = 31 * hashCode + Objects.hashCode(modeAsString());
hashCode = 31 * hashCode + Objects.hashCode(privacyAsString());
hashCode = 31 * hashCode + Objects.hashCode(metadata());
hashCode = 31 * hashCode + Objects.hashCode(createdBy());
hashCode = 31 * hashCode + Objects.hashCode(createdTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(lastMessageTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedTimestamp());
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 Channel)) {
return false;
}
Channel other = (Channel) obj;
return Objects.equals(name(), other.name()) && Objects.equals(channelArn(), other.channelArn())
&& Objects.equals(modeAsString(), other.modeAsString())
&& Objects.equals(privacyAsString(), other.privacyAsString()) && Objects.equals(metadata(), other.metadata())
&& Objects.equals(createdBy(), other.createdBy()) && Objects.equals(createdTimestamp(), other.createdTimestamp())
&& Objects.equals(lastMessageTimestamp(), other.lastMessageTimestamp())
&& Objects.equals(lastUpdatedTimestamp(), other.lastUpdatedTimestamp());
}
/**
* 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("Channel").add("Name", name() == null ? null : "*** Sensitive Data Redacted ***")
.add("ChannelArn", channelArn()).add("Mode", modeAsString()).add("Privacy", privacyAsString())
.add("Metadata", metadata() == null ? null : "*** Sensitive Data Redacted ***").add("CreatedBy", createdBy())
.add("CreatedTimestamp", createdTimestamp()).add("LastMessageTimestamp", lastMessageTimestamp())
.add("LastUpdatedTimestamp", lastUpdatedTimestamp()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "ChannelArn":
return Optional.ofNullable(clazz.cast(channelArn()));
case "Mode":
return Optional.ofNullable(clazz.cast(modeAsString()));
case "Privacy":
return Optional.ofNullable(clazz.cast(privacyAsString()));
case "Metadata":
return Optional.ofNullable(clazz.cast(metadata()));
case "CreatedBy":
return Optional.ofNullable(clazz.cast(createdBy()));
case "CreatedTimestamp":
return Optional.ofNullable(clazz.cast(createdTimestamp()));
case "LastMessageTimestamp":
return Optional.ofNullable(clazz.cast(lastMessageTimestamp()));
case "LastUpdatedTimestamp":
return Optional.ofNullable(clazz.cast(lastUpdatedTimestamp()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function