software.amazon.awssdk.services.pinpoint.model.HoldoutActivity Maven / Gradle / Ivy
Show all versions of pinpoint 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.pinpoint.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.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;
/**
*
* Specifies the settings for a holdout activity in a journey. This type of activity stops a journey for a specified
* percentage of participants.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class HoldoutActivity implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NEXT_ACTIVITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NextActivity").getter(getter(HoldoutActivity::nextActivity)).setter(setter(Builder::nextActivity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextActivity").build()).build();
private static final SdkField PERCENTAGE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Percentage").getter(getter(HoldoutActivity::percentage)).setter(setter(Builder::percentage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Percentage").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NEXT_ACTIVITY_FIELD,
PERCENTAGE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("NextActivity", NEXT_ACTIVITY_FIELD);
put("Percentage", PERCENTAGE_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String nextActivity;
private final Integer percentage;
private HoldoutActivity(BuilderImpl builder) {
this.nextActivity = builder.nextActivity;
this.percentage = builder.percentage;
}
/**
*
* The unique identifier for the next activity to perform, after performing the holdout activity.
*
*
* @return The unique identifier for the next activity to perform, after performing the holdout activity.
*/
public final String nextActivity() {
return nextActivity;
}
/**
*
* The percentage of participants who shouldn't continue the journey.
*
*
* To determine which participants are held out, Amazon Pinpoint applies a probability-based algorithm to the
* percentage that you specify. Therefore, the actual percentage of participants who are held out may not be equal
* to the percentage that you specify.
*
*
* @return The percentage of participants who shouldn't continue the journey.
*
* To determine which participants are held out, Amazon Pinpoint applies a probability-based algorithm to
* the percentage that you specify. Therefore, the actual percentage of participants who are held out may
* not be equal to the percentage that you specify.
*/
public final Integer percentage() {
return percentage;
}
@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(nextActivity());
hashCode = 31 * hashCode + Objects.hashCode(percentage());
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 HoldoutActivity)) {
return false;
}
HoldoutActivity other = (HoldoutActivity) obj;
return Objects.equals(nextActivity(), other.nextActivity()) && Objects.equals(percentage(), other.percentage());
}
/**
* 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("HoldoutActivity").add("NextActivity", nextActivity()).add("Percentage", percentage()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "NextActivity":
return Optional.ofNullable(clazz.cast(nextActivity()));
case "Percentage":
return Optional.ofNullable(clazz.cast(percentage()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function
*
* To determine which participants are held out, Amazon Pinpoint applies a probability-based algorithm to
* the percentage that you specify. Therefore, the actual percentage of participants who are held out may
* not be equal to the percentage that you specify.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder percentage(Integer percentage);
}
static final class BuilderImpl implements Builder {
private String nextActivity;
private Integer percentage;
private BuilderImpl() {
}
private BuilderImpl(HoldoutActivity model) {
nextActivity(model.nextActivity);
percentage(model.percentage);
}
public final String getNextActivity() {
return nextActivity;
}
public final void setNextActivity(String nextActivity) {
this.nextActivity = nextActivity;
}
@Override
public final Builder nextActivity(String nextActivity) {
this.nextActivity = nextActivity;
return this;
}
public final Integer getPercentage() {
return percentage;
}
public final void setPercentage(Integer percentage) {
this.percentage = percentage;
}
@Override
public final Builder percentage(Integer percentage) {
this.percentage = percentage;
return this;
}
@Override
public HoldoutActivity build() {
return new HoldoutActivity(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
@Override
public Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
}
}