* The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.
*
*
* @return The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.
*/
public final String campaignArn() {
return campaignArn;
}
/**
*
* The number of results to return. The default is 25. If you are including metadata in recommendations, the maximum
* is 50. Otherwise, the maximum is 500.
*
*
* @return The number of results to return. The default is 25. If you are including metadata in recommendations, the
* maximum is 50. Otherwise, the maximum is 500.
*/
public final Integer numResults() {
return numResults;
}
/**
* For responses, this returns true if the service returned a value for the Context 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 hasContext() {
return context != null && !(context instanceof SdkAutoConstructMap);
}
/**
*
* The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction
* information that might be relevant when getting a user's recommendations, such as the user's current location or
* device type.
*
*
* 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 #hasContext} method.
*
*
* @return The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction
* information that might be relevant when getting a user's recommendations, such as the user's current
* location or device type.
*/
public final Map context() {
return context;
}
/**
*
* The ARN of the filter to apply to the returned recommendations. For more information, see Filtering Recommendations .
*
*
* When using this parameter, be sure the filter resource is ACTIVE
.
*
*
* @return The ARN of the filter to apply to the returned recommendations. For more information, see Filtering Recommendations .
*
* When using this parameter, be sure the filter resource is ACTIVE
.
*/
public final String filterArn() {
return filterArn;
}
/**
* For responses, this returns true if the service returned a value for the FilterValues 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 hasFilterValues() {
return filterValues != null && !(filterValues instanceof SdkAutoConstructMap);
}
/**
*
* The values to use when filtering recommendations. For each placeholder parameter in your filter expression,
* provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value.
* Separate multiple values for one parameter with a comma.
*
*
* For filter expressions that use an INCLUDE
element to include items, you must provide values for all
* parameters that are defined in the expression. For filters with expressions that use an EXCLUDE
* element to exclude items, you can omit the filter-values
.In this case, Amazon Personalize doesn't
* use that portion of the expression to filter recommendations.
*
*
* For more information, see Filtering
* recommendations and user segments .
*
*
* 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 #hasFilterValues} method.
*
*
* @return The values to use when filtering recommendations. For each placeholder parameter in your filter
* expression, provide the parameter name (in matching case) as a key and the filter value(s) as the
* corresponding value. Separate multiple values for one parameter with a comma.
*
* For filter expressions that use an INCLUDE
element to include items, you must provide values
* for all parameters that are defined in the expression. For filters with expressions that use an
* EXCLUDE
element to exclude items, you can omit the filter-values
.In this case,
* Amazon Personalize doesn't use that portion of the expression to filter recommendations.
*
*
* For more information, see Filtering recommendations and user
* segments .
*/
public final Map filterValues() {
return filterValues;
}
/**
*
* The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you
* created a Domain dataset group with a recommender for a domain use case.
*
*
* @return The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender
* ARN if you created a Domain dataset group with a recommender for a domain use case.
*/
public final String recommenderArn() {
return recommenderArn;
}
/**
* For responses, this returns true if the service returned a value for the Promotions 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 hasPromotions() {
return promotions != null && !(promotions instanceof SdkAutoConstructList);
}
/**
*
* The promotions to apply to the recommendation request. A promotion defines additional business rules that apply
* to a configurable subset of recommended 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 #hasPromotions} method.
*
*
* @return The promotions to apply to the recommendation request. A promotion defines additional business rules that
* apply to a configurable subset of recommended items.
*/
public final List promotions() {
return promotions;
}
/**
* For responses, this returns true if the service returned a value for the MetadataColumns 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 hasMetadataColumns() {
return metadataColumns != null && !(metadataColumns instanceof SdkAutoConstructMap);
}
/**
*
* If you enabled metadata in recommendations when you created or updated the campaign or recommender, specify the
* metadata columns from your Items dataset to include in item recommendations. The map key is ITEMS
* and the value is a list of column names from your Items dataset. The maximum number of columns you can provide is
* 10.
*
*
* For information about enabling metadata for a campaign, see Enabling
* metadata in recommendations for a campaign . For information about enabling metadata for a recommender, see Enabling metadata in recommendations for a recommender .
*
*
* 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 #hasMetadataColumns} method.
*
*
* @return If you enabled metadata in recommendations when you created or updated the campaign or recommender,
* specify the metadata columns from your Items dataset to include in item recommendations. The map key is
* ITEMS
and the value is a list of column names from your Items dataset. The maximum number of
* columns you can provide is 10.
*
* For information about enabling metadata for a campaign, see Enabling metadata in recommendations for a campaign . For information about enabling metadata for a
* recommender, see Enabling metadata in recommendations for a recommender .
*/
public final Map> metadataColumns() {
return metadataColumns;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(campaignArn());
hashCode = 31 * hashCode + Objects.hashCode(itemId());
hashCode = 31 * hashCode + Objects.hashCode(userId());
hashCode = 31 * hashCode + Objects.hashCode(numResults());
hashCode = 31 * hashCode + Objects.hashCode(hasContext() ? context() : null);
hashCode = 31 * hashCode + Objects.hashCode(filterArn());
hashCode = 31 * hashCode + Objects.hashCode(hasFilterValues() ? filterValues() : null);
hashCode = 31 * hashCode + Objects.hashCode(recommenderArn());
hashCode = 31 * hashCode + Objects.hashCode(hasPromotions() ? promotions() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasMetadataColumns() ? metadataColumns() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetRecommendationsRequest)) {
return false;
}
GetRecommendationsRequest other = (GetRecommendationsRequest) obj;
return Objects.equals(campaignArn(), other.campaignArn()) && Objects.equals(itemId(), other.itemId())
&& Objects.equals(userId(), other.userId()) && Objects.equals(numResults(), other.numResults())
&& hasContext() == other.hasContext() && Objects.equals(context(), other.context())
&& Objects.equals(filterArn(), other.filterArn()) && hasFilterValues() == other.hasFilterValues()
&& Objects.equals(filterValues(), other.filterValues())
&& Objects.equals(recommenderArn(), other.recommenderArn()) && hasPromotions() == other.hasPromotions()
&& Objects.equals(promotions(), other.promotions()) && hasMetadataColumns() == other.hasMetadataColumns()
&& Objects.equals(metadataColumns(), other.metadataColumns());
}
/**
* 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("GetRecommendationsRequest").add("CampaignArn", campaignArn()).add("ItemId", itemId())
.add("UserId", userId()).add("NumResults", numResults())
.add("Context", context() == null ? null : "*** Sensitive Data Redacted ***").add("FilterArn", filterArn())
.add("FilterValues", filterValues() == null ? null : "*** Sensitive Data Redacted ***")
.add("RecommenderArn", recommenderArn()).add("Promotions", hasPromotions() ? promotions() : null)
.add("MetadataColumns", hasMetadataColumns() ? metadataColumns() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "campaignArn":
return Optional.ofNullable(clazz.cast(campaignArn()));
case "itemId":
return Optional.ofNullable(clazz.cast(itemId()));
case "userId":
return Optional.ofNullable(clazz.cast(userId()));
case "numResults":
return Optional.ofNullable(clazz.cast(numResults()));
case "context":
return Optional.ofNullable(clazz.cast(context()));
case "filterArn":
return Optional.ofNullable(clazz.cast(filterArn()));
case "filterValues":
return Optional.ofNullable(clazz.cast(filterValues()));
case "recommenderArn":
return Optional.ofNullable(clazz.cast(recommenderArn()));
case "promotions":
return Optional.ofNullable(clazz.cast(promotions()));
case "metadataColumns":
return Optional.ofNullable(clazz.cast(metadataColumns()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((GetRecommendationsRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends PersonalizeRuntimeRequest.Builder, SdkPojo,
CopyableBuilder {
/**
*
* The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.
*
*
* @param campaignArn
* The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder campaignArn(String campaignArn);
/**
*
* The item ID to provide recommendations for.
*
*
* Required for RELATED_ITEMS
recipe type.
*
*
* @param itemId
* The item ID to provide recommendations for.
*
* Required for RELATED_ITEMS
recipe type.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder itemId(String itemId);
/**
*
* The user ID to provide recommendations for.
*
*
* Required for USER_PERSONALIZATION
recipe type.
*
*
* @param userId
* The user ID to provide recommendations for.
*
* Required for USER_PERSONALIZATION
recipe type.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder userId(String userId);
/**
*
* The number of results to return. The default is 25. If you are including metadata in recommendations, the
* maximum is 50. Otherwise, the maximum is 500.
*
*
* @param numResults
* The number of results to return. The default is 25. If you are including metadata in recommendations,
* the maximum is 50. Otherwise, the maximum is 500.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder numResults(Integer numResults);
/**
*
* The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction
* information that might be relevant when getting a user's recommendations, such as the user's current location
* or device type.
*
*
* @param context
* The contextual metadata to use when getting recommendations. Contextual metadata includes any
* interaction information that might be relevant when getting a user's recommendations, such as the
* user's current location or device type.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder context(Map context);
/**
*
* The ARN of the filter to apply to the returned recommendations. For more information, see Filtering Recommendations .
*
*
* When using this parameter, be sure the filter resource is ACTIVE
.
*
*
* @param filterArn
* The ARN of the filter to apply to the returned recommendations. For more information, see Filtering
* Recommendations .
*
* When using this parameter, be sure the filter resource is ACTIVE
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder filterArn(String filterArn);
/**
*
* The values to use when filtering recommendations. For each placeholder parameter in your filter expression,
* provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value.
* Separate multiple values for one parameter with a comma.
*
*
* For filter expressions that use an INCLUDE
element to include items, you must provide values for
* all parameters that are defined in the expression. For filters with expressions that use an
* EXCLUDE
element to exclude items, you can omit the filter-values
.In this case,
* Amazon Personalize doesn't use that portion of the expression to filter recommendations.
*
*
* For more information, see Filtering
* recommendations and user segments .
*
*
* @param filterValues
* The values to use when filtering recommendations. For each placeholder parameter in your filter
* expression, provide the parameter name (in matching case) as a key and the filter value(s) as the
* corresponding value. Separate multiple values for one parameter with a comma.
*
* For filter expressions that use an INCLUDE
element to include items, you must provide
* values for all parameters that are defined in the expression. For filters with expressions that use an
* EXCLUDE
element to exclude items, you can omit the filter-values
.In this
* case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.
*
*
* For more information, see Filtering recommendations and
* user segments .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder filterValues(Map filterValues);
/**
*
* The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if
* you created a Domain dataset group with a recommender for a domain use case.
*
*
* @param recommenderArn
* The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender
* ARN if you created a Domain dataset group with a recommender for a domain use case.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder recommenderArn(String recommenderArn);
/**
*
* The promotions to apply to the recommendation request. A promotion defines additional business rules that
* apply to a configurable subset of recommended items.
*
*
* @param promotions
* The promotions to apply to the recommendation request. A promotion defines additional business rules
* that apply to a configurable subset of recommended items.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder promotions(Collection promotions);
/**
*
* The promotions to apply to the recommendation request. A promotion defines additional business rules that
* apply to a configurable subset of recommended items.
*
*
* @param promotions
* The promotions to apply to the recommendation request. A promotion defines additional business rules
* that apply to a configurable subset of recommended items.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder promotions(Promotion... promotions);
/**
*
* The promotions to apply to the recommendation request. A promotion defines additional business rules that
* apply to a configurable subset of recommended items.
*
* This is a convenience method that creates an instance of the
* {@link software.amazon.awssdk.services.personalizeruntime.model.Promotion.Builder} avoiding the need to
* create one manually via {@link software.amazon.awssdk.services.personalizeruntime.model.Promotion#builder()}.
*
*
* When the {@link Consumer} completes,
* {@link software.amazon.awssdk.services.personalizeruntime.model.Promotion.Builder#build()} is called
* immediately and its result is passed to {@link #promotions(List)}.
*
* @param promotions
* a consumer that will call methods on
* {@link software.amazon.awssdk.services.personalizeruntime.model.Promotion.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #promotions(java.util.Collection)
*/
Builder promotions(Consumer... promotions);
/**
*
* If you enabled metadata in recommendations when you created or updated the campaign or recommender, specify
* the metadata columns from your Items dataset to include in item recommendations. The map key is
* ITEMS
and the value is a list of column names from your Items dataset. The maximum number of
* columns you can provide is 10.
*
*
* For information about enabling metadata for a campaign, see Enabling metadata in recommendations for a campaign . For information about enabling metadata for a
* recommender, see Enabling metadata in recommendations for a recommender .
*
*
* @param metadataColumns
* If you enabled metadata in recommendations when you created or updated the campaign or recommender,
* specify the metadata columns from your Items dataset to include in item recommendations. The map key
* is ITEMS
and the value is a list of column names from your Items dataset. The maximum
* number of columns you can provide is 10.
*
* For information about enabling metadata for a campaign, see Enabling metadata in recommendations for a campaign . For information about enabling metadata for
* a recommender, see Enabling metadata in recommendations for a recommender .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder metadataColumns(Map> metadataColumns);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends PersonalizeRuntimeRequest.BuilderImpl implements Builder {
private String campaignArn;
private String itemId;
private String userId;
private Integer numResults;
private Map context = DefaultSdkAutoConstructMap.getInstance();
private String filterArn;
private Map filterValues = DefaultSdkAutoConstructMap.getInstance();
private String recommenderArn;
private List promotions = DefaultSdkAutoConstructList.getInstance();
private Map> metadataColumns = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(GetRecommendationsRequest model) {
super(model);
campaignArn(model.campaignArn);
itemId(model.itemId);
userId(model.userId);
numResults(model.numResults);
context(model.context);
filterArn(model.filterArn);
filterValues(model.filterValues);
recommenderArn(model.recommenderArn);
promotions(model.promotions);
metadataColumns(model.metadataColumns);
}
public final String getCampaignArn() {
return campaignArn;
}
public final void setCampaignArn(String campaignArn) {
this.campaignArn = campaignArn;
}
@Override
public final Builder campaignArn(String campaignArn) {
this.campaignArn = campaignArn;
return this;
}
public final String getItemId() {
return itemId;
}
public final void setItemId(String itemId) {
this.itemId = itemId;
}
@Override
public final Builder itemId(String itemId) {
this.itemId = itemId;
return this;
}
public final String getUserId() {
return userId;
}
public final void setUserId(String userId) {
this.userId = userId;
}
@Override
public final Builder userId(String userId) {
this.userId = userId;
return this;
}
public final Integer getNumResults() {
return numResults;
}
public final void setNumResults(Integer numResults) {
this.numResults = numResults;
}
@Override
public final Builder numResults(Integer numResults) {
this.numResults = numResults;
return this;
}
public final Map getContext() {
if (context instanceof SdkAutoConstructMap) {
return null;
}
return context;
}
public final void setContext(Map context) {
this.context = ContextCopier.copy(context);
}
@Override
public final Builder context(Map context) {
this.context = ContextCopier.copy(context);
return this;
}
public final String getFilterArn() {
return filterArn;
}
public final void setFilterArn(String filterArn) {
this.filterArn = filterArn;
}
@Override
public final Builder filterArn(String filterArn) {
this.filterArn = filterArn;
return this;
}
public final Map getFilterValues() {
if (filterValues instanceof SdkAutoConstructMap) {
return null;
}
return filterValues;
}
public final void setFilterValues(Map filterValues) {
this.filterValues = FilterValuesCopier.copy(filterValues);
}
@Override
public final Builder filterValues(Map filterValues) {
this.filterValues = FilterValuesCopier.copy(filterValues);
return this;
}
public final String getRecommenderArn() {
return recommenderArn;
}
public final void setRecommenderArn(String recommenderArn) {
this.recommenderArn = recommenderArn;
}
@Override
public final Builder recommenderArn(String recommenderArn) {
this.recommenderArn = recommenderArn;
return this;
}
public final List getPromotions() {
List result = PromotionListCopier.copyToBuilder(this.promotions);
if (result instanceof SdkAutoConstructList) {
return null;
}
return result;
}
public final void setPromotions(Collection promotions) {
this.promotions = PromotionListCopier.copyFromBuilder(promotions);
}
@Override
public final Builder promotions(Collection promotions) {
this.promotions = PromotionListCopier.copy(promotions);
return this;
}
@Override
@SafeVarargs
public final Builder promotions(Promotion... promotions) {
promotions(Arrays.asList(promotions));
return this;
}
@Override
@SafeVarargs
public final Builder promotions(Consumer... promotions) {
promotions(Stream.of(promotions).map(c -> Promotion.builder().applyMutation(c).build()).collect(Collectors.toList()));
return this;
}
public final Map> getMetadataColumns() {
if (metadataColumns instanceof SdkAutoConstructMap) {
return null;
}
return metadataColumns;
}
public final void setMetadataColumns(Map> metadataColumns) {
this.metadataColumns = MetadataColumnsCopier.copy(metadataColumns);
}
@Override
public final Builder metadataColumns(Map> metadataColumns) {
this.metadataColumns = MetadataColumnsCopier.copy(metadataColumns);
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public GetRecommendationsRequest build() {
return new GetRecommendationsRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}