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.SolutionConfig Maven / Gradle / Ivy
/*
* 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;
/**
*
* Describes the configuration properties for the solution.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SolutionConfig implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField EVENT_VALUE_THRESHOLD_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("eventValueThreshold").getter(getter(SolutionConfig::eventValueThreshold))
.setter(setter(Builder::eventValueThreshold))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("eventValueThreshold").build())
.build();
private static final SdkField HPO_CONFIG_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("hpoConfig").getter(getter(SolutionConfig::hpoConfig)).setter(setter(Builder::hpoConfig))
.constructor(HPOConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("hpoConfig").build()).build();
private static final SdkField> ALGORITHM_HYPER_PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("algorithmHyperParameters")
.getter(getter(SolutionConfig::algorithmHyperParameters))
.setter(setter(Builder::algorithmHyperParameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("algorithmHyperParameters").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> FEATURE_TRANSFORMATION_PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("featureTransformationParameters")
.getter(getter(SolutionConfig::featureTransformationParameters))
.setter(setter(Builder::featureTransformationParameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("featureTransformationParameters")
.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 AUTO_ML_CONFIG_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("autoMLConfig").getter(getter(SolutionConfig::autoMLConfig)).setter(setter(Builder::autoMLConfig))
.constructor(AutoMLConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("autoMLConfig").build()).build();
private static final SdkField OPTIMIZATION_OBJECTIVE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("optimizationObjective")
.getter(getter(SolutionConfig::optimizationObjective)).setter(setter(Builder::optimizationObjective))
.constructor(OptimizationObjective::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("optimizationObjective").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(EVENT_VALUE_THRESHOLD_FIELD,
HPO_CONFIG_FIELD, ALGORITHM_HYPER_PARAMETERS_FIELD, FEATURE_TRANSFORMATION_PARAMETERS_FIELD, AUTO_ML_CONFIG_FIELD,
OPTIMIZATION_OBJECTIVE_FIELD));
private static final long serialVersionUID = 1L;
private final String eventValueThreshold;
private final HPOConfig hpoConfig;
private final Map algorithmHyperParameters;
private final Map featureTransformationParameters;
private final AutoMLConfig autoMLConfig;
private final OptimizationObjective optimizationObjective;
private SolutionConfig(BuilderImpl builder) {
this.eventValueThreshold = builder.eventValueThreshold;
this.hpoConfig = builder.hpoConfig;
this.algorithmHyperParameters = builder.algorithmHyperParameters;
this.featureTransformationParameters = builder.featureTransformationParameters;
this.autoMLConfig = builder.autoMLConfig;
this.optimizationObjective = builder.optimizationObjective;
}
/**
*
* Only events with a value greater than or equal to this threshold are used for training a model.
*
*
* @return Only events with a value greater than or equal to this threshold are used for training a model.
*/
public final String eventValueThreshold() {
return eventValueThreshold;
}
/**
*
* Describes the properties for hyperparameter optimization (HPO).
*
*
* @return Describes the properties for hyperparameter optimization (HPO).
*/
public final HPOConfig hpoConfig() {
return hpoConfig;
}
/**
* For responses, this returns true if the service returned a value for the AlgorithmHyperParameters 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 hasAlgorithmHyperParameters() {
return algorithmHyperParameters != null && !(algorithmHyperParameters instanceof SdkAutoConstructMap);
}
/**
*
* Lists the hyperparameter names and ranges.
*
*
* 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 #hasAlgorithmHyperParameters} method.
*
*
* @return Lists the hyperparameter names and ranges.
*/
public final Map algorithmHyperParameters() {
return algorithmHyperParameters;
}
/**
* For responses, this returns true if the service returned a value for the FeatureTransformationParameters
* 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 hasFeatureTransformationParameters() {
return featureTransformationParameters != null && !(featureTransformationParameters instanceof SdkAutoConstructMap);
}
/**
*
* Lists the feature transformation parameters.
*
*
* 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 #hasFeatureTransformationParameters}
* method.
*
*
* @return Lists the feature transformation parameters.
*/
public final Map featureTransformationParameters() {
return featureTransformationParameters;
}
/**
*
* The AutoMLConfig object
* containing a list of recipes to search when AutoML is performed.
*
*
* @return The AutoMLConfig
* object containing a list of recipes to search when AutoML is performed.
*/
public final AutoMLConfig autoMLConfig() {
return autoMLConfig;
}
/**
*
* Describes the additional objective for the solution, such as maximizing streaming minutes or increasing revenue.
* For more information see Optimizing a
* solution .
*
*
* @return Describes the additional objective for the solution, such as maximizing streaming minutes or increasing
* revenue. For more information see Optimizing a solution .
*/
public final OptimizationObjective optimizationObjective() {
return optimizationObjective;
}
@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(eventValueThreshold());
hashCode = 31 * hashCode + Objects.hashCode(hpoConfig());
hashCode = 31 * hashCode + Objects.hashCode(hasAlgorithmHyperParameters() ? algorithmHyperParameters() : null);
hashCode = 31 * hashCode
+ Objects.hashCode(hasFeatureTransformationParameters() ? featureTransformationParameters() : null);
hashCode = 31 * hashCode + Objects.hashCode(autoMLConfig());
hashCode = 31 * hashCode + Objects.hashCode(optimizationObjective());
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 SolutionConfig)) {
return false;
}
SolutionConfig other = (SolutionConfig) obj;
return Objects.equals(eventValueThreshold(), other.eventValueThreshold())
&& Objects.equals(hpoConfig(), other.hpoConfig())
&& hasAlgorithmHyperParameters() == other.hasAlgorithmHyperParameters()
&& Objects.equals(algorithmHyperParameters(), other.algorithmHyperParameters())
&& hasFeatureTransformationParameters() == other.hasFeatureTransformationParameters()
&& Objects.equals(featureTransformationParameters(), other.featureTransformationParameters())
&& Objects.equals(autoMLConfig(), other.autoMLConfig())
&& Objects.equals(optimizationObjective(), other.optimizationObjective());
}
/**
* 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("SolutionConfig")
.add("EventValueThreshold", eventValueThreshold())
.add("HpoConfig", hpoConfig())
.add("AlgorithmHyperParameters", hasAlgorithmHyperParameters() ? algorithmHyperParameters() : null)
.add("FeatureTransformationParameters",
hasFeatureTransformationParameters() ? featureTransformationParameters() : null)
.add("AutoMLConfig", autoMLConfig()).add("OptimizationObjective", optimizationObjective()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "eventValueThreshold":
return Optional.ofNullable(clazz.cast(eventValueThreshold()));
case "hpoConfig":
return Optional.ofNullable(clazz.cast(hpoConfig()));
case "algorithmHyperParameters":
return Optional.ofNullable(clazz.cast(algorithmHyperParameters()));
case "featureTransformationParameters":
return Optional.ofNullable(clazz.cast(featureTransformationParameters()));
case "autoMLConfig":
return Optional.ofNullable(clazz.cast(autoMLConfig()));
case "optimizationObjective":
return Optional.ofNullable(clazz.cast(optimizationObjective()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((SolutionConfig) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* Only events with a value greater than or equal to this threshold are used for training a model.
*
*
* @param eventValueThreshold
* Only events with a value greater than or equal to this threshold are used for training a model.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder eventValueThreshold(String eventValueThreshold);
/**
*
* Describes the properties for hyperparameter optimization (HPO).
*
*
* @param hpoConfig
* Describes the properties for hyperparameter optimization (HPO).
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder hpoConfig(HPOConfig hpoConfig);
/**
*
* Describes the properties for hyperparameter optimization (HPO).
*
* This is a convenience method that creates an instance of the {@link HPOConfig.Builder} avoiding the need to
* create one manually via {@link HPOConfig#builder()}.
*
*
* When the {@link Consumer} completes, {@link HPOConfig.Builder#build()} is called immediately and its result
* is passed to {@link #hpoConfig(HPOConfig)}.
*
* @param hpoConfig
* a consumer that will call methods on {@link HPOConfig.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #hpoConfig(HPOConfig)
*/
default Builder hpoConfig(Consumer hpoConfig) {
return hpoConfig(HPOConfig.builder().applyMutation(hpoConfig).build());
}
/**
*
* Lists the hyperparameter names and ranges.
*
*
* @param algorithmHyperParameters
* Lists the hyperparameter names and ranges.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder algorithmHyperParameters(Map algorithmHyperParameters);
/**
*
* Lists the feature transformation parameters.
*
*
* @param featureTransformationParameters
* Lists the feature transformation parameters.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder featureTransformationParameters(Map featureTransformationParameters);
/**
*
* The AutoMLConfig object
* containing a list of recipes to search when AutoML is performed.
*
*
* @param autoMLConfig
* The AutoMLConfig
* object containing a list of recipes to search when AutoML is performed.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder autoMLConfig(AutoMLConfig autoMLConfig);
/**
*
* The AutoMLConfig object
* containing a list of recipes to search when AutoML is performed.
*
* This is a convenience method that creates an instance of the {@link AutoMLConfig.Builder} avoiding the need
* to create one manually via {@link AutoMLConfig#builder()}.
*
*
* When the {@link Consumer} completes, {@link AutoMLConfig.Builder#build()} is called immediately and its
* result is passed to {@link #autoMLConfig(AutoMLConfig)}.
*
* @param autoMLConfig
* a consumer that will call methods on {@link AutoMLConfig.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #autoMLConfig(AutoMLConfig)
*/
default Builder autoMLConfig(Consumer autoMLConfig) {
return autoMLConfig(AutoMLConfig.builder().applyMutation(autoMLConfig).build());
}
/**
*
* Describes the additional objective for the solution, such as maximizing streaming minutes or increasing
* revenue. For more information see Optimizing a
* solution .
*
*
* @param optimizationObjective
* Describes the additional objective for the solution, such as maximizing streaming minutes or
* increasing revenue. For more information see Optimizing a solution .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder optimizationObjective(OptimizationObjective optimizationObjective);
/**
*
* Describes the additional objective for the solution, such as maximizing streaming minutes or increasing
* revenue. For more information see Optimizing a
* solution .
*
* This is a convenience method that creates an instance of the {@link OptimizationObjective.Builder} avoiding
* the need to create one manually via {@link OptimizationObjective#builder()}.
*
*
* When the {@link Consumer} completes, {@link OptimizationObjective.Builder#build()} is called immediately and
* its result is passed to {@link #optimizationObjective(OptimizationObjective)}.
*
* @param optimizationObjective
* a consumer that will call methods on {@link OptimizationObjective.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #optimizationObjective(OptimizationObjective)
*/
default Builder optimizationObjective(Consumer optimizationObjective) {
return optimizationObjective(OptimizationObjective.builder().applyMutation(optimizationObjective).build());
}
}
static final class BuilderImpl implements Builder {
private String eventValueThreshold;
private HPOConfig hpoConfig;
private Map algorithmHyperParameters = DefaultSdkAutoConstructMap.getInstance();
private Map featureTransformationParameters = DefaultSdkAutoConstructMap.getInstance();
private AutoMLConfig autoMLConfig;
private OptimizationObjective optimizationObjective;
private BuilderImpl() {
}
private BuilderImpl(SolutionConfig model) {
eventValueThreshold(model.eventValueThreshold);
hpoConfig(model.hpoConfig);
algorithmHyperParameters(model.algorithmHyperParameters);
featureTransformationParameters(model.featureTransformationParameters);
autoMLConfig(model.autoMLConfig);
optimizationObjective(model.optimizationObjective);
}
public final String getEventValueThreshold() {
return eventValueThreshold;
}
public final void setEventValueThreshold(String eventValueThreshold) {
this.eventValueThreshold = eventValueThreshold;
}
@Override
public final Builder eventValueThreshold(String eventValueThreshold) {
this.eventValueThreshold = eventValueThreshold;
return this;
}
public final HPOConfig.Builder getHpoConfig() {
return hpoConfig != null ? hpoConfig.toBuilder() : null;
}
public final void setHpoConfig(HPOConfig.BuilderImpl hpoConfig) {
this.hpoConfig = hpoConfig != null ? hpoConfig.build() : null;
}
@Override
public final Builder hpoConfig(HPOConfig hpoConfig) {
this.hpoConfig = hpoConfig;
return this;
}
public final Map getAlgorithmHyperParameters() {
if (algorithmHyperParameters instanceof SdkAutoConstructMap) {
return null;
}
return algorithmHyperParameters;
}
public final void setAlgorithmHyperParameters(Map algorithmHyperParameters) {
this.algorithmHyperParameters = HyperParametersCopier.copy(algorithmHyperParameters);
}
@Override
public final Builder algorithmHyperParameters(Map algorithmHyperParameters) {
this.algorithmHyperParameters = HyperParametersCopier.copy(algorithmHyperParameters);
return this;
}
public final Map getFeatureTransformationParameters() {
if (featureTransformationParameters instanceof SdkAutoConstructMap) {
return null;
}
return featureTransformationParameters;
}
public final void setFeatureTransformationParameters(Map featureTransformationParameters) {
this.featureTransformationParameters = FeatureTransformationParametersCopier.copy(featureTransformationParameters);
}
@Override
public final Builder featureTransformationParameters(Map featureTransformationParameters) {
this.featureTransformationParameters = FeatureTransformationParametersCopier.copy(featureTransformationParameters);
return this;
}
public final AutoMLConfig.Builder getAutoMLConfig() {
return autoMLConfig != null ? autoMLConfig.toBuilder() : null;
}
public final void setAutoMLConfig(AutoMLConfig.BuilderImpl autoMLConfig) {
this.autoMLConfig = autoMLConfig != null ? autoMLConfig.build() : null;
}
@Override
public final Builder autoMLConfig(AutoMLConfig autoMLConfig) {
this.autoMLConfig = autoMLConfig;
return this;
}
public final OptimizationObjective.Builder getOptimizationObjective() {
return optimizationObjective != null ? optimizationObjective.toBuilder() : null;
}
public final void setOptimizationObjective(OptimizationObjective.BuilderImpl optimizationObjective) {
this.optimizationObjective = optimizationObjective != null ? optimizationObjective.build() : null;
}
@Override
public final Builder optimizationObjective(OptimizationObjective optimizationObjective) {
this.optimizationObjective = optimizationObjective;
return this;
}
@Override
public SolutionConfig build() {
return new SolutionConfig(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}