Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.personalize.model.RecommenderConfig Maven / Gradle / Ivy
Go to download
The AWS Java SDK for Personalize module holds the client classes that are used for
communicating with Personalize.
/*
* 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.personalize.model;
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;
/**
*
* The configuration details of the recommender.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class RecommenderConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField> ITEM_EXPLORATION_CONFIG_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("itemExplorationConfig")
.getter(getter(RecommenderConfig::itemExplorationConfig))
.setter(setter(Builder::itemExplorationConfig))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("itemExplorationConfig").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 SdkField MIN_RECOMMENDATION_REQUESTS_PER_SECOND_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("minRecommendationRequestsPerSecond")
.getter(getter(RecommenderConfig::minRecommendationRequestsPerSecond))
.setter(setter(Builder::minRecommendationRequestsPerSecond))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("minRecommendationRequestsPerSecond")
.build()).build();
private static final SdkField TRAINING_DATA_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("trainingDataConfig")
.getter(getter(RecommenderConfig::trainingDataConfig)).setter(setter(Builder::trainingDataConfig))
.constructor(TrainingDataConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("trainingDataConfig").build())
.build();
private static final SdkField ENABLE_METADATA_WITH_RECOMMENDATIONS_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("enableMetadataWithRecommendations")
.getter(getter(RecommenderConfig::enableMetadataWithRecommendations))
.setter(setter(Builder::enableMetadataWithRecommendations))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("enableMetadataWithRecommendations")
.build()).build();
private static final List> SDK_FIELDS = Collections
.unmodifiableList(Arrays.asList(ITEM_EXPLORATION_CONFIG_FIELD, MIN_RECOMMENDATION_REQUESTS_PER_SECOND_FIELD,
TRAINING_DATA_CONFIG_FIELD, ENABLE_METADATA_WITH_RECOMMENDATIONS_FIELD));
private static final long serialVersionUID = 1L;
private final Map itemExplorationConfig;
private final Integer minRecommendationRequestsPerSecond;
private final TrainingDataConfig trainingDataConfig;
private final Boolean enableMetadataWithRecommendations;
private RecommenderConfig(BuilderImpl builder) {
this.itemExplorationConfig = builder.itemExplorationConfig;
this.minRecommendationRequestsPerSecond = builder.minRecommendationRequestsPerSecond;
this.trainingDataConfig = builder.trainingDataConfig;
this.enableMetadataWithRecommendations = builder.enableMetadataWithRecommendations;
}
/**
* For responses, this returns true if the service returned a value for the ItemExplorationConfig 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 hasItemExplorationConfig() {
return itemExplorationConfig != null && !(itemExplorationConfig instanceof SdkAutoConstructMap);
}
/**
*
* Specifies the exploration configuration hyperparameters, including explorationWeight
and
* explorationItemAgeCutOff
, you want to use to configure the amount of item exploration Amazon
* Personalize uses when recommending items. Provide itemExplorationConfig
data only if your
* recommenders generate personalized recommendations for a user (not popular items or similar items).
*
*
* 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 #hasItemExplorationConfig} method.
*
*
* @return Specifies the exploration configuration hyperparameters, including explorationWeight
and
* explorationItemAgeCutOff
, you want to use to configure the amount of item exploration Amazon
* Personalize uses when recommending items. Provide itemExplorationConfig
data only if your
* recommenders generate personalized recommendations for a user (not popular items or similar items).
*/
public final Map itemExplorationConfig() {
return itemExplorationConfig;
}
/**
*
* Specifies the requested minimum provisioned recommendation requests per second that Amazon Personalize will
* support. A high minRecommendationRequestsPerSecond
will increase your bill. We recommend starting
* with 1 for minRecommendationRequestsPerSecond
(the default). Track your usage using Amazon
* CloudWatch metrics, and increase the minRecommendationRequestsPerSecond
as necessary.
*
*
* @return Specifies the requested minimum provisioned recommendation requests per second that Amazon Personalize
* will support. A high minRecommendationRequestsPerSecond
will increase your bill. We
* recommend starting with 1 for minRecommendationRequestsPerSecond
(the default). Track your
* usage using Amazon CloudWatch metrics, and increase the minRecommendationRequestsPerSecond
* as necessary.
*/
public final Integer minRecommendationRequestsPerSecond() {
return minRecommendationRequestsPerSecond;
}
/**
*
* Specifies the training data configuration to use when creating a domain recommender.
*
*
* @return Specifies the training data configuration to use when creating a domain recommender.
*/
public final TrainingDataConfig trainingDataConfig() {
return trainingDataConfig;
}
/**
*
* Whether metadata with recommendations is enabled for the recommender. If enabled, you can specify the columns
* from your Items dataset in your request for recommendations. Amazon Personalize returns this data for each item
* in the recommendation response. For information about enabling metadata for a recommender, see Enabling metadata in recommendations for a recommender .
*
*
* If you enable metadata in recommendations, you will incur additional costs. For more information, see Amazon Personalize pricing .
*
*
* @return Whether metadata with recommendations is enabled for the recommender. If enabled, you can specify the
* columns from your Items dataset in your request for recommendations. Amazon Personalize returns this data
* for each item in the recommendation response. For information about enabling metadata for a recommender,
* see Enabling metadata in recommendations for a recommender .
*
* If you enable metadata in recommendations, you will incur additional costs. For more information, see Amazon Personalize pricing .
*/
public final Boolean enableMetadataWithRecommendations() {
return enableMetadataWithRecommendations;
}
@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(hasItemExplorationConfig() ? itemExplorationConfig() : null);
hashCode = 31 * hashCode + Objects.hashCode(minRecommendationRequestsPerSecond());
hashCode = 31 * hashCode + Objects.hashCode(trainingDataConfig());
hashCode = 31 * hashCode + Objects.hashCode(enableMetadataWithRecommendations());
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 RecommenderConfig)) {
return false;
}
RecommenderConfig other = (RecommenderConfig) obj;
return hasItemExplorationConfig() == other.hasItemExplorationConfig()
&& Objects.equals(itemExplorationConfig(), other.itemExplorationConfig())
&& Objects.equals(minRecommendationRequestsPerSecond(), other.minRecommendationRequestsPerSecond())
&& Objects.equals(trainingDataConfig(), other.trainingDataConfig())
&& Objects.equals(enableMetadataWithRecommendations(), other.enableMetadataWithRecommendations());
}
/**
* 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("RecommenderConfig")
.add("ItemExplorationConfig", hasItemExplorationConfig() ? itemExplorationConfig() : null)
.add("MinRecommendationRequestsPerSecond", minRecommendationRequestsPerSecond())
.add("TrainingDataConfig", trainingDataConfig())
.add("EnableMetadataWithRecommendations", enableMetadataWithRecommendations()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "itemExplorationConfig":
return Optional.ofNullable(clazz.cast(itemExplorationConfig()));
case "minRecommendationRequestsPerSecond":
return Optional.ofNullable(clazz.cast(minRecommendationRequestsPerSecond()));
case "trainingDataConfig":
return Optional.ofNullable(clazz.cast(trainingDataConfig()));
case "enableMetadataWithRecommendations":
return Optional.ofNullable(clazz.cast(enableMetadataWithRecommendations()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((RecommenderConfig) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* Specifies the exploration configuration hyperparameters, including explorationWeight
and
* explorationItemAgeCutOff
, you want to use to configure the amount of item exploration Amazon
* Personalize uses when recommending items. Provide itemExplorationConfig
data only if your
* recommenders generate personalized recommendations for a user (not popular items or similar items).
*
*
* @param itemExplorationConfig
* Specifies the exploration configuration hyperparameters, including explorationWeight
and
* explorationItemAgeCutOff
, you want to use to configure the amount of item exploration
* Amazon Personalize uses when recommending items. Provide itemExplorationConfig
data only
* if your recommenders generate personalized recommendations for a user (not popular items or similar
* items).
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder itemExplorationConfig(Map itemExplorationConfig);
/**
*
* Specifies the requested minimum provisioned recommendation requests per second that Amazon Personalize will
* support. A high minRecommendationRequestsPerSecond
will increase your bill. We recommend
* starting with 1 for minRecommendationRequestsPerSecond
(the default). Track your usage using
* Amazon CloudWatch metrics, and increase the minRecommendationRequestsPerSecond
as necessary.
*
*
* @param minRecommendationRequestsPerSecond
* Specifies the requested minimum provisioned recommendation requests per second that Amazon Personalize
* will support. A high minRecommendationRequestsPerSecond
will increase your bill. We
* recommend starting with 1 for minRecommendationRequestsPerSecond
(the default). Track
* your usage using Amazon CloudWatch metrics, and increase the
* minRecommendationRequestsPerSecond
as necessary.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder minRecommendationRequestsPerSecond(Integer minRecommendationRequestsPerSecond);
/**
*
* Specifies the training data configuration to use when creating a domain recommender.
*
*
* @param trainingDataConfig
* Specifies the training data configuration to use when creating a domain recommender.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder trainingDataConfig(TrainingDataConfig trainingDataConfig);
/**
*
* Specifies the training data configuration to use when creating a domain recommender.
*
* This is a convenience method that creates an instance of the {@link TrainingDataConfig.Builder} avoiding the
* need to create one manually via {@link TrainingDataConfig#builder()}.
*
*
* When the {@link Consumer} completes, {@link TrainingDataConfig.Builder#build()} is called immediately and its
* result is passed to {@link #trainingDataConfig(TrainingDataConfig)}.
*
* @param trainingDataConfig
* a consumer that will call methods on {@link TrainingDataConfig.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #trainingDataConfig(TrainingDataConfig)
*/
default Builder trainingDataConfig(Consumer trainingDataConfig) {
return trainingDataConfig(TrainingDataConfig.builder().applyMutation(trainingDataConfig).build());
}
/**
*
* Whether metadata with recommendations is enabled for the recommender. If enabled, you can specify the columns
* from your Items dataset in your request for recommendations. Amazon Personalize returns this data for each
* item in the recommendation response. For information about enabling metadata for a recommender, see Enabling metadata in recommendations for a recommender .
*
*
* If you enable metadata in recommendations, you will incur additional costs. For more information, see Amazon Personalize pricing .
*
*
* @param enableMetadataWithRecommendations
* Whether metadata with recommendations is enabled for the recommender. If enabled, you can specify the
* columns from your Items dataset in your request for recommendations. Amazon Personalize returns this
* data for each item in the recommendation response. For information about enabling metadata for a
* recommender, see Enabling metadata in recommendations for a recommender .
*
* If you enable metadata in recommendations, you will incur additional costs. For more information, see
* Amazon Personalize pricing .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder enableMetadataWithRecommendations(Boolean enableMetadataWithRecommendations);
}
static final class BuilderImpl implements Builder {
private Map itemExplorationConfig = DefaultSdkAutoConstructMap.getInstance();
private Integer minRecommendationRequestsPerSecond;
private TrainingDataConfig trainingDataConfig;
private Boolean enableMetadataWithRecommendations;
private BuilderImpl() {
}
private BuilderImpl(RecommenderConfig model) {
itemExplorationConfig(model.itemExplorationConfig);
minRecommendationRequestsPerSecond(model.minRecommendationRequestsPerSecond);
trainingDataConfig(model.trainingDataConfig);
enableMetadataWithRecommendations(model.enableMetadataWithRecommendations);
}
public final Map getItemExplorationConfig() {
if (itemExplorationConfig instanceof SdkAutoConstructMap) {
return null;
}
return itemExplorationConfig;
}
public final void setItemExplorationConfig(Map itemExplorationConfig) {
this.itemExplorationConfig = HyperParametersCopier.copy(itemExplorationConfig);
}
@Override
public final Builder itemExplorationConfig(Map itemExplorationConfig) {
this.itemExplorationConfig = HyperParametersCopier.copy(itemExplorationConfig);
return this;
}
public final Integer getMinRecommendationRequestsPerSecond() {
return minRecommendationRequestsPerSecond;
}
public final void setMinRecommendationRequestsPerSecond(Integer minRecommendationRequestsPerSecond) {
this.minRecommendationRequestsPerSecond = minRecommendationRequestsPerSecond;
}
@Override
public final Builder minRecommendationRequestsPerSecond(Integer minRecommendationRequestsPerSecond) {
this.minRecommendationRequestsPerSecond = minRecommendationRequestsPerSecond;
return this;
}
public final TrainingDataConfig.Builder getTrainingDataConfig() {
return trainingDataConfig != null ? trainingDataConfig.toBuilder() : null;
}
public final void setTrainingDataConfig(TrainingDataConfig.BuilderImpl trainingDataConfig) {
this.trainingDataConfig = trainingDataConfig != null ? trainingDataConfig.build() : null;
}
@Override
public final Builder trainingDataConfig(TrainingDataConfig trainingDataConfig) {
this.trainingDataConfig = trainingDataConfig;
return this;
}
public final Boolean getEnableMetadataWithRecommendations() {
return enableMetadataWithRecommendations;
}
public final void setEnableMetadataWithRecommendations(Boolean enableMetadataWithRecommendations) {
this.enableMetadataWithRecommendations = enableMetadataWithRecommendations;
}
@Override
public final Builder enableMetadataWithRecommendations(Boolean enableMetadataWithRecommendations) {
this.enableMetadataWithRecommendations = enableMetadataWithRecommendations;
return this;
}
@Override
public RecommenderConfig build() {
return new RecommenderConfig(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}