software.amazon.awssdk.services.wellarchitected.model.ReviewTemplateAnswerSummary Maven / Gradle / Ivy
Show all versions of wellarchitected 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.wellarchitected.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The summary of review template answers.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReviewTemplateAnswerSummary implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField QUESTION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("QuestionId").getter(getter(ReviewTemplateAnswerSummary::questionId)).setter(setter(Builder::questionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QuestionId").build()).build();
private static final SdkField PILLAR_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PillarId").getter(getter(ReviewTemplateAnswerSummary::pillarId)).setter(setter(Builder::pillarId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PillarId").build()).build();
private static final SdkField QUESTION_TITLE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("QuestionTitle").getter(getter(ReviewTemplateAnswerSummary::questionTitle))
.setter(setter(Builder::questionTitle))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QuestionTitle").build()).build();
private static final SdkField> CHOICES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Choices")
.getter(getter(ReviewTemplateAnswerSummary::choices))
.setter(setter(Builder::choices))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Choices").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Choice::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> SELECTED_CHOICES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SelectedChoices")
.getter(getter(ReviewTemplateAnswerSummary::selectedChoices))
.setter(setter(Builder::selectedChoices))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SelectedChoices").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> CHOICE_ANSWER_SUMMARIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ChoiceAnswerSummaries")
.getter(getter(ReviewTemplateAnswerSummary::choiceAnswerSummaries))
.setter(setter(Builder::choiceAnswerSummaries))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ChoiceAnswerSummaries").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ChoiceAnswerSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField IS_APPLICABLE_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("IsApplicable").getter(getter(ReviewTemplateAnswerSummary::isApplicable))
.setter(setter(Builder::isApplicable))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IsApplicable").build()).build();
private static final SdkField ANSWER_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AnswerStatus").getter(getter(ReviewTemplateAnswerSummary::answerStatusAsString))
.setter(setter(Builder::answerStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnswerStatus").build()).build();
private static final SdkField REASON_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Reason")
.getter(getter(ReviewTemplateAnswerSummary::reasonAsString)).setter(setter(Builder::reason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Reason").build()).build();
private static final SdkField QUESTION_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("QuestionType").getter(getter(ReviewTemplateAnswerSummary::questionTypeAsString))
.setter(setter(Builder::questionType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QuestionType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(QUESTION_ID_FIELD,
PILLAR_ID_FIELD, QUESTION_TITLE_FIELD, CHOICES_FIELD, SELECTED_CHOICES_FIELD, CHOICE_ANSWER_SUMMARIES_FIELD,
IS_APPLICABLE_FIELD, ANSWER_STATUS_FIELD, REASON_FIELD, QUESTION_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String questionId;
private final String pillarId;
private final String questionTitle;
private final List choices;
private final List selectedChoices;
private final List choiceAnswerSummaries;
private final Boolean isApplicable;
private final String answerStatus;
private final String reason;
private final String questionType;
private ReviewTemplateAnswerSummary(BuilderImpl builder) {
this.questionId = builder.questionId;
this.pillarId = builder.pillarId;
this.questionTitle = builder.questionTitle;
this.choices = builder.choices;
this.selectedChoices = builder.selectedChoices;
this.choiceAnswerSummaries = builder.choiceAnswerSummaries;
this.isApplicable = builder.isApplicable;
this.answerStatus = builder.answerStatus;
this.reason = builder.reason;
this.questionType = builder.questionType;
}
/**
* Returns the value of the QuestionId property for this object.
*
* @return The value of the QuestionId property for this object.
*/
public final String questionId() {
return questionId;
}
/**
* Returns the value of the PillarId property for this object.
*
* @return The value of the PillarId property for this object.
*/
public final String pillarId() {
return pillarId;
}
/**
* Returns the value of the QuestionTitle property for this object.
*
* @return The value of the QuestionTitle property for this object.
*/
public final String questionTitle() {
return questionTitle;
}
/**
* For responses, this returns true if the service returned a value for the Choices property. This DOES NOT check
* that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
* useful because the SDK will never return a null collection or map, but you may need to differentiate between the
* service returning nothing (or null) and the service returning an empty collection or map. For requests, this
* returns true if a value for the property was specified in the request builder, and false if a value was not
* specified.
*/
public final boolean hasChoices() {
return choices != null && !(choices instanceof SdkAutoConstructList);
}
/**
* Returns the value of the Choices property for this object.
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasChoices} method.
*
*
* @return The value of the Choices property for this object.
*/
public final List choices() {
return choices;
}
/**
* For responses, this returns true if the service returned a value for the SelectedChoices property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasSelectedChoices() {
return selectedChoices != null && !(selectedChoices instanceof SdkAutoConstructList);
}
/**
* Returns the value of the SelectedChoices property for this object.
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasSelectedChoices} method.
*
*
* @return The value of the SelectedChoices property for this object.
*/
public final List selectedChoices() {
return selectedChoices;
}
/**
* For responses, this returns true if the service returned a value for the ChoiceAnswerSummaries property. This
* DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the
* property). This is useful because the SDK will never return a null collection or map, but you may need to
* differentiate between the service returning nothing (or null) and the service returning an empty collection or
* map. For requests, this returns true if a value for the property was specified in the request builder, and false
* if a value was not specified.
*/
public final boolean hasChoiceAnswerSummaries() {
return choiceAnswerSummaries != null && !(choiceAnswerSummaries instanceof SdkAutoConstructList);
}
/**
*
* A list of selected choices to a question in the review template.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasChoiceAnswerSummaries} method.
*
*
* @return A list of selected choices to a question in the review template.
*/
public final List choiceAnswerSummaries() {
return choiceAnswerSummaries;
}
/**
* Returns the value of the IsApplicable property for this object.
*
* @return The value of the IsApplicable property for this object.
*/
public final Boolean isApplicable() {
return isApplicable;
}
/**
*
* The status of whether or not this question has been answered.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #answerStatus} will
* return {@link ReviewTemplateAnswerStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #answerStatusAsString}.
*
*
* @return The status of whether or not this question has been answered.
* @see ReviewTemplateAnswerStatus
*/
public final ReviewTemplateAnswerStatus answerStatus() {
return ReviewTemplateAnswerStatus.fromValue(answerStatus);
}
/**
*
* The status of whether or not this question has been answered.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #answerStatus} will
* return {@link ReviewTemplateAnswerStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #answerStatusAsString}.
*
*
* @return The status of whether or not this question has been answered.
* @see ReviewTemplateAnswerStatus
*/
public final String answerStatusAsString() {
return answerStatus;
}
/**
*
* The reason why a choice is not-applicable to a question in the review template.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #reason} will
* return {@link AnswerReason#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #reasonAsString}.
*
*
* @return The reason why a choice is not-applicable to a question in the review template.
* @see AnswerReason
*/
public final AnswerReason reason() {
return AnswerReason.fromValue(reason);
}
/**
*
* The reason why a choice is not-applicable to a question in the review template.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #reason} will
* return {@link AnswerReason#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #reasonAsString}.
*
*
* @return The reason why a choice is not-applicable to a question in the review template.
* @see AnswerReason
*/
public final String reasonAsString() {
return reason;
}
/**
*
* The type of question.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #questionType} will
* return {@link QuestionType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #questionTypeAsString}.
*
*
* @return The type of question.
* @see QuestionType
*/
public final QuestionType questionType() {
return QuestionType.fromValue(questionType);
}
/**
*
* The type of question.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #questionType} will
* return {@link QuestionType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #questionTypeAsString}.
*
*
* @return The type of question.
* @see QuestionType
*/
public final String questionTypeAsString() {
return questionType;
}
@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(questionId());
hashCode = 31 * hashCode + Objects.hashCode(pillarId());
hashCode = 31 * hashCode + Objects.hashCode(questionTitle());
hashCode = 31 * hashCode + Objects.hashCode(hasChoices() ? choices() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasSelectedChoices() ? selectedChoices() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasChoiceAnswerSummaries() ? choiceAnswerSummaries() : null);
hashCode = 31 * hashCode + Objects.hashCode(isApplicable());
hashCode = 31 * hashCode + Objects.hashCode(answerStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(reasonAsString());
hashCode = 31 * hashCode + Objects.hashCode(questionTypeAsString());
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 ReviewTemplateAnswerSummary)) {
return false;
}
ReviewTemplateAnswerSummary other = (ReviewTemplateAnswerSummary) obj;
return Objects.equals(questionId(), other.questionId()) && Objects.equals(pillarId(), other.pillarId())
&& Objects.equals(questionTitle(), other.questionTitle()) && hasChoices() == other.hasChoices()
&& Objects.equals(choices(), other.choices()) && hasSelectedChoices() == other.hasSelectedChoices()
&& Objects.equals(selectedChoices(), other.selectedChoices())
&& hasChoiceAnswerSummaries() == other.hasChoiceAnswerSummaries()
&& Objects.equals(choiceAnswerSummaries(), other.choiceAnswerSummaries())
&& Objects.equals(isApplicable(), other.isApplicable())
&& Objects.equals(answerStatusAsString(), other.answerStatusAsString())
&& Objects.equals(reasonAsString(), other.reasonAsString())
&& Objects.equals(questionTypeAsString(), other.questionTypeAsString());
}
/**
* 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("ReviewTemplateAnswerSummary").add("QuestionId", questionId()).add("PillarId", pillarId())
.add("QuestionTitle", questionTitle()).add("Choices", hasChoices() ? choices() : null)
.add("SelectedChoices", hasSelectedChoices() ? selectedChoices() : null)
.add("ChoiceAnswerSummaries", hasChoiceAnswerSummaries() ? choiceAnswerSummaries() : null)
.add("IsApplicable", isApplicable()).add("AnswerStatus", answerStatusAsString()).add("Reason", reasonAsString())
.add("QuestionType", questionTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "QuestionId":
return Optional.ofNullable(clazz.cast(questionId()));
case "PillarId":
return Optional.ofNullable(clazz.cast(pillarId()));
case "QuestionTitle":
return Optional.ofNullable(clazz.cast(questionTitle()));
case "Choices":
return Optional.ofNullable(clazz.cast(choices()));
case "SelectedChoices":
return Optional.ofNullable(clazz.cast(selectedChoices()));
case "ChoiceAnswerSummaries":
return Optional.ofNullable(clazz.cast(choiceAnswerSummaries()));
case "IsApplicable":
return Optional.ofNullable(clazz.cast(isApplicable()));
case "AnswerStatus":
return Optional.ofNullable(clazz.cast(answerStatusAsString()));
case "Reason":
return Optional.ofNullable(clazz.cast(reasonAsString()));
case "QuestionType":
return Optional.ofNullable(clazz.cast(questionTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function