software.amazon.awssdk.services.workdocs.model.Comment Maven / Gradle / Ivy
Show all versions of workdocs Show documentation
/*
* 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.workdocs.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;
/**
*
* Describes a comment.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Comment implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField COMMENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CommentId").getter(getter(Comment::commentId)).setter(setter(Builder::commentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CommentId").build()).build();
private static final SdkField PARENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ParentId").getter(getter(Comment::parentId)).setter(setter(Builder::parentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParentId").build()).build();
private static final SdkField THREAD_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ThreadId").getter(getter(Comment::threadId)).setter(setter(Builder::threadId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ThreadId").build()).build();
private static final SdkField TEXT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Text")
.getter(getter(Comment::text)).setter(setter(Builder::text))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Text").build()).build();
private static final SdkField CONTRIBUTOR_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Contributor").getter(getter(Comment::contributor)).setter(setter(Builder::contributor))
.constructor(User::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Contributor").build()).build();
private static final SdkField CREATED_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedTimestamp").getter(getter(Comment::createdTimestamp)).setter(setter(Builder::createdTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTimestamp").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(Comment::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField VISIBILITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Visibility").getter(getter(Comment::visibilityAsString)).setter(setter(Builder::visibility))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Visibility").build()).build();
private static final SdkField RECIPIENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RecipientId").getter(getter(Comment::recipientId)).setter(setter(Builder::recipientId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecipientId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(COMMENT_ID_FIELD,
PARENT_ID_FIELD, THREAD_ID_FIELD, TEXT_FIELD, CONTRIBUTOR_FIELD, CREATED_TIMESTAMP_FIELD, STATUS_FIELD,
VISIBILITY_FIELD, RECIPIENT_ID_FIELD));
private static final long serialVersionUID = 1L;
private final String commentId;
private final String parentId;
private final String threadId;
private final String text;
private final User contributor;
private final Instant createdTimestamp;
private final String status;
private final String visibility;
private final String recipientId;
private Comment(BuilderImpl builder) {
this.commentId = builder.commentId;
this.parentId = builder.parentId;
this.threadId = builder.threadId;
this.text = builder.text;
this.contributor = builder.contributor;
this.createdTimestamp = builder.createdTimestamp;
this.status = builder.status;
this.visibility = builder.visibility;
this.recipientId = builder.recipientId;
}
/**
*
* The ID of the comment.
*
*
* @return The ID of the comment.
*/
public final String commentId() {
return commentId;
}
/**
*
* The ID of the parent comment.
*
*
* @return The ID of the parent comment.
*/
public final String parentId() {
return parentId;
}
/**
*
* The ID of the root comment in the thread.
*
*
* @return The ID of the root comment in the thread.
*/
public final String threadId() {
return threadId;
}
/**
*
* The text of the comment.
*
*
* @return The text of the comment.
*/
public final String text() {
return text;
}
/**
*
* The details of the user who made the comment.
*
*
* @return The details of the user who made the comment.
*/
public final User contributor() {
return contributor;
}
/**
*
* The time that the comment was created.
*
*
* @return The time that the comment was created.
*/
public final Instant createdTimestamp() {
return createdTimestamp;
}
/**
*
* The status of the comment.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link CommentStatusType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the comment.
* @see CommentStatusType
*/
public final CommentStatusType status() {
return CommentStatusType.fromValue(status);
}
/**
*
* The status of the comment.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link CommentStatusType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the comment.
* @see CommentStatusType
*/
public final String statusAsString() {
return status;
}
/**
*
* The visibility of the comment. Options are either PRIVATE, where the comment is visible only to the comment
* author and document owner and co-owners, or PUBLIC, where the comment is visible to document owners, co-owners,
* and contributors.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #visibility} will
* return {@link CommentVisibilityType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #visibilityAsString}.
*
*
* @return The visibility of the comment. Options are either PRIVATE, where the comment is visible only to the
* comment author and document owner and co-owners, or PUBLIC, where the comment is visible to document
* owners, co-owners, and contributors.
* @see CommentVisibilityType
*/
public final CommentVisibilityType visibility() {
return CommentVisibilityType.fromValue(visibility);
}
/**
*
* The visibility of the comment. Options are either PRIVATE, where the comment is visible only to the comment
* author and document owner and co-owners, or PUBLIC, where the comment is visible to document owners, co-owners,
* and contributors.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #visibility} will
* return {@link CommentVisibilityType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #visibilityAsString}.
*
*
* @return The visibility of the comment. Options are either PRIVATE, where the comment is visible only to the
* comment author and document owner and co-owners, or PUBLIC, where the comment is visible to document
* owners, co-owners, and contributors.
* @see CommentVisibilityType
*/
public final String visibilityAsString() {
return visibility;
}
/**
*
* If the comment is a reply to another user's comment, this field contains the user ID of the user being replied
* to.
*
*
* @return If the comment is a reply to another user's comment, this field contains the user ID of the user being
* replied to.
*/
public final String recipientId() {
return recipientId;
}
@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(commentId());
hashCode = 31 * hashCode + Objects.hashCode(parentId());
hashCode = 31 * hashCode + Objects.hashCode(threadId());
hashCode = 31 * hashCode + Objects.hashCode(text());
hashCode = 31 * hashCode + Objects.hashCode(contributor());
hashCode = 31 * hashCode + Objects.hashCode(createdTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(visibilityAsString());
hashCode = 31 * hashCode + Objects.hashCode(recipientId());
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 Comment)) {
return false;
}
Comment other = (Comment) obj;
return Objects.equals(commentId(), other.commentId()) && Objects.equals(parentId(), other.parentId())
&& Objects.equals(threadId(), other.threadId()) && Objects.equals(text(), other.text())
&& Objects.equals(contributor(), other.contributor())
&& Objects.equals(createdTimestamp(), other.createdTimestamp())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(visibilityAsString(), other.visibilityAsString())
&& Objects.equals(recipientId(), other.recipientId());
}
/**
* 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("Comment").add("CommentId", commentId()).add("ParentId", parentId()).add("ThreadId", threadId())
.add("Text", text() == null ? null : "*** Sensitive Data Redacted ***").add("Contributor", contributor())
.add("CreatedTimestamp", createdTimestamp()).add("Status", statusAsString())
.add("Visibility", visibilityAsString()).add("RecipientId", recipientId()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CommentId":
return Optional.ofNullable(clazz.cast(commentId()));
case "ParentId":
return Optional.ofNullable(clazz.cast(parentId()));
case "ThreadId":
return Optional.ofNullable(clazz.cast(threadId()));
case "Text":
return Optional.ofNullable(clazz.cast(text()));
case "Contributor":
return Optional.ofNullable(clazz.cast(contributor()));
case "CreatedTimestamp":
return Optional.ofNullable(clazz.cast(createdTimestamp()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "Visibility":
return Optional.ofNullable(clazz.cast(visibilityAsString()));
case "RecipientId":
return Optional.ofNullable(clazz.cast(recipientId()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function