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

software.amazon.awssdk.services.lexruntime.model.PredictedIntent Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon Lex Runtime module holds the client classes that are used for communicating with Amazon Lex Runtime Service

There is a newer version: 2.30.1
Show newest version
/*
 * 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.lexruntime.model;

import java.beans.Transient;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
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.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* An intent that Amazon Lex suggests satisfies the user's intent. Includes the name of the intent, the confidence that * Amazon Lex has that the user's intent is satisfied, and the slots defined for the intent. *

*/ @Generated("software.amazon.awssdk:codegen") public final class PredictedIntent implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField INTENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("intentName").getter(getter(PredictedIntent::intentName)).setter(setter(Builder::intentName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("intentName").build()).build(); private static final SdkField NLU_INTENT_CONFIDENCE_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("nluIntentConfidence") .getter(getter(PredictedIntent::nluIntentConfidence)).setter(setter(Builder::nluIntentConfidence)) .constructor(IntentConfidence::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("nluIntentConfidence").build()) .build(); private static final SdkField> SLOTS_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("slots") .getter(getter(PredictedIntent::slots)) .setter(setter(Builder::slots)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("slots").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INTENT_NAME_FIELD, NLU_INTENT_CONFIDENCE_FIELD, SLOTS_FIELD)); private static final long serialVersionUID = 1L; private final String intentName; private final IntentConfidence nluIntentConfidence; private final Map slots; private PredictedIntent(BuilderImpl builder) { this.intentName = builder.intentName; this.nluIntentConfidence = builder.nluIntentConfidence; this.slots = builder.slots; } /** *

* The name of the intent that Amazon Lex suggests satisfies the user's intent. *

* * @return The name of the intent that Amazon Lex suggests satisfies the user's intent. */ public final String intentName() { return intentName; } /** *

* Indicates how confident Amazon Lex is that an intent satisfies the user's intent. *

* * @return Indicates how confident Amazon Lex is that an intent satisfies the user's intent. */ public final IntentConfidence nluIntentConfidence() { return nluIntentConfidence; } /** * For responses, this returns true if the service returned a value for the Slots 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 hasSlots() { return slots != null && !(slots instanceof SdkAutoConstructMap); } /** *

* The slot and slot values associated with the predicted intent. *

*

* 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 #hasSlots} method. *

* * @return The slot and slot values associated with the predicted intent. */ public final Map slots() { return slots; } @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(intentName()); hashCode = 31 * hashCode + Objects.hashCode(nluIntentConfidence()); hashCode = 31 * hashCode + Objects.hashCode(hasSlots() ? slots() : null); 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 PredictedIntent)) { return false; } PredictedIntent other = (PredictedIntent) obj; return Objects.equals(intentName(), other.intentName()) && Objects.equals(nluIntentConfidence(), other.nluIntentConfidence()) && hasSlots() == other.hasSlots() && Objects.equals(slots(), other.slots()); } /** * 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("PredictedIntent").add("IntentName", intentName()) .add("NluIntentConfidence", nluIntentConfidence()) .add("Slots", slots() == null ? null : "*** Sensitive Data Redacted ***").build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "intentName": return Optional.ofNullable(clazz.cast(intentName())); case "nluIntentConfidence": return Optional.ofNullable(clazz.cast(nluIntentConfidence())); case "slots": return Optional.ofNullable(clazz.cast(slots())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((PredictedIntent) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The name of the intent that Amazon Lex suggests satisfies the user's intent. *

* * @param intentName * The name of the intent that Amazon Lex suggests satisfies the user's intent. * @return Returns a reference to this object so that method calls can be chained together. */ Builder intentName(String intentName); /** *

* Indicates how confident Amazon Lex is that an intent satisfies the user's intent. *

* * @param nluIntentConfidence * Indicates how confident Amazon Lex is that an intent satisfies the user's intent. * @return Returns a reference to this object so that method calls can be chained together. */ Builder nluIntentConfidence(IntentConfidence nluIntentConfidence); /** *

* Indicates how confident Amazon Lex is that an intent satisfies the user's intent. *

* This is a convenience that creates an instance of the {@link IntentConfidence.Builder} avoiding the need to * create one manually via {@link IntentConfidence#builder()}. * * When the {@link Consumer} completes, {@link IntentConfidence.Builder#build()} is called immediately and its * result is passed to {@link #nluIntentConfidence(IntentConfidence)}. * * @param nluIntentConfidence * a consumer that will call methods on {@link IntentConfidence.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #nluIntentConfidence(IntentConfidence) */ default Builder nluIntentConfidence(Consumer nluIntentConfidence) { return nluIntentConfidence(IntentConfidence.builder().applyMutation(nluIntentConfidence).build()); } /** *

* The slot and slot values associated with the predicted intent. *

* * @param slots * The slot and slot values associated with the predicted intent. * @return Returns a reference to this object so that method calls can be chained together. */ Builder slots(Map slots); } static final class BuilderImpl implements Builder { private String intentName; private IntentConfidence nluIntentConfidence; private Map slots = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(PredictedIntent model) { intentName(model.intentName); nluIntentConfidence(model.nluIntentConfidence); slots(model.slots); } public final String getIntentName() { return intentName; } public final void setIntentName(String intentName) { this.intentName = intentName; } @Override @Transient public final Builder intentName(String intentName) { this.intentName = intentName; return this; } public final IntentConfidence.Builder getNluIntentConfidence() { return nluIntentConfidence != null ? nluIntentConfidence.toBuilder() : null; } public final void setNluIntentConfidence(IntentConfidence.BuilderImpl nluIntentConfidence) { this.nluIntentConfidence = nluIntentConfidence != null ? nluIntentConfidence.build() : null; } @Override @Transient public final Builder nluIntentConfidence(IntentConfidence nluIntentConfidence) { this.nluIntentConfidence = nluIntentConfidence; return this; } public final Map getSlots() { if (slots instanceof SdkAutoConstructMap) { return null; } return slots; } public final void setSlots(Map slots) { this.slots = StringMapCopier.copy(slots); } @Override @Transient public final Builder slots(Map slots) { this.slots = StringMapCopier.copy(slots); return this; } @Override public PredictedIntent build() { return new PredictedIntent(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy