software.amazon.awssdk.services.wisdom.model.RecommendationData Maven / Gradle / Ivy
Show all versions of wisdom 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.wisdom.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*
* Information about the recommendation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class RecommendationData implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField DOCUMENT_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("document").getter(getter(RecommendationData::document)).setter(setter(Builder::document))
.constructor(Document::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("document").build()).build();
private static final SdkField RECOMMENDATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("recommendationId").getter(getter(RecommendationData::recommendationId))
.setter(setter(Builder::recommendationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("recommendationId").build()).build();
private static final SdkField RELEVANCE_LEVEL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("relevanceLevel").getter(getter(RecommendationData::relevanceLevelAsString))
.setter(setter(Builder::relevanceLevel))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("relevanceLevel").build()).build();
private static final SdkField RELEVANCE_SCORE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("relevanceScore").getter(getter(RecommendationData::relevanceScore))
.setter(setter(Builder::relevanceScore))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("relevanceScore").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("type")
.getter(getter(RecommendationData::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("type").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DOCUMENT_FIELD,
RECOMMENDATION_ID_FIELD, RELEVANCE_LEVEL_FIELD, RELEVANCE_SCORE_FIELD, TYPE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final Document document;
private final String recommendationId;
private final String relevanceLevel;
private final Double relevanceScore;
private final String type;
private RecommendationData(BuilderImpl builder) {
this.document = builder.document;
this.recommendationId = builder.recommendationId;
this.relevanceLevel = builder.relevanceLevel;
this.relevanceScore = builder.relevanceScore;
this.type = builder.type;
}
/**
*
* The recommended document.
*
*
* @return The recommended document.
*/
public final Document document() {
return document;
}
/**
*
* The identifier of the recommendation.
*
*
* @return The identifier of the recommendation.
*/
public final String recommendationId() {
return recommendationId;
}
/**
*
* The relevance level of the recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #relevanceLevel}
* will return {@link RelevanceLevel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #relevanceLevelAsString}.
*
*
* @return The relevance level of the recommendation.
* @see RelevanceLevel
*/
public final RelevanceLevel relevanceLevel() {
return RelevanceLevel.fromValue(relevanceLevel);
}
/**
*
* The relevance level of the recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #relevanceLevel}
* will return {@link RelevanceLevel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #relevanceLevelAsString}.
*
*
* @return The relevance level of the recommendation.
* @see RelevanceLevel
*/
public final String relevanceLevelAsString() {
return relevanceLevel;
}
/**
*
* The relevance score of the recommendation.
*
*
* @return The relevance score of the recommendation.
*/
public final Double relevanceScore() {
return relevanceScore;
}
/**
*
* The type of recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link RecommendationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of recommendation.
* @see RecommendationType
*/
public final RecommendationType type() {
return RecommendationType.fromValue(type);
}
/**
*
* The type of recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link RecommendationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of recommendation.
* @see RecommendationType
*/
public final String typeAsString() {
return type;
}
@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(document());
hashCode = 31 * hashCode + Objects.hashCode(recommendationId());
hashCode = 31 * hashCode + Objects.hashCode(relevanceLevelAsString());
hashCode = 31 * hashCode + Objects.hashCode(relevanceScore());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
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 RecommendationData)) {
return false;
}
RecommendationData other = (RecommendationData) obj;
return Objects.equals(document(), other.document()) && Objects.equals(recommendationId(), other.recommendationId())
&& Objects.equals(relevanceLevelAsString(), other.relevanceLevelAsString())
&& Objects.equals(relevanceScore(), other.relevanceScore())
&& Objects.equals(typeAsString(), other.typeAsString());
}
/**
* 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("RecommendationData").add("Document", document()).add("RecommendationId", recommendationId())
.add("RelevanceLevel", relevanceLevelAsString()).add("RelevanceScore", relevanceScore())
.add("Type", typeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "document":
return Optional.ofNullable(clazz.cast(document()));
case "recommendationId":
return Optional.ofNullable(clazz.cast(recommendationId()));
case "relevanceLevel":
return Optional.ofNullable(clazz.cast(relevanceLevelAsString()));
case "relevanceScore":
return Optional.ofNullable(clazz.cast(relevanceScore()));
case "type":
return Optional.ofNullable(clazz.cast(typeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("document", DOCUMENT_FIELD);
map.put("recommendationId", RECOMMENDATION_ID_FIELD);
map.put("relevanceLevel", RELEVANCE_LEVEL_FIELD);
map.put("relevanceScore", RELEVANCE_SCORE_FIELD);
map.put("type", TYPE_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function