software.amazon.awssdk.services.pinpoint.model.WriteTreatmentResource 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.List;
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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Specifies the settings for a campaign treatment. A treatment is a variation of a campaign that's used for A/B
* testing of a campaign.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class WriteTreatmentResource implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField CUSTOM_DELIVERY_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("CustomDeliveryConfiguration")
.getter(getter(WriteTreatmentResource::customDeliveryConfiguration))
.setter(setter(Builder::customDeliveryConfiguration))
.constructor(CustomDeliveryConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomDeliveryConfiguration")
.build()).build();
private static final SdkField MESSAGE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("MessageConfiguration")
.getter(getter(WriteTreatmentResource::messageConfiguration)).setter(setter(Builder::messageConfiguration))
.constructor(MessageConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MessageConfiguration").build())
.build();
private static final SdkField SCHEDULE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Schedule").getter(getter(WriteTreatmentResource::schedule)).setter(setter(Builder::schedule))
.constructor(Schedule::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Schedule").build()).build();
private static final SdkField SIZE_PERCENT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("SizePercent").getter(getter(WriteTreatmentResource::sizePercent)).setter(setter(Builder::sizePercent))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SizePercent").build()).build();
private static final SdkField TEMPLATE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TemplateConfiguration")
.getter(getter(WriteTreatmentResource::templateConfiguration)).setter(setter(Builder::templateConfiguration))
.constructor(TemplateConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateConfiguration").build())
.build();
private static final SdkField TREATMENT_DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TreatmentDescription").getter(getter(WriteTreatmentResource::treatmentDescription))
.setter(setter(Builder::treatmentDescription))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TreatmentDescription").build())
.build();
private static final SdkField TREATMENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TreatmentName").getter(getter(WriteTreatmentResource::treatmentName))
.setter(setter(Builder::treatmentName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TreatmentName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
CUSTOM_DELIVERY_CONFIGURATION_FIELD, MESSAGE_CONFIGURATION_FIELD, SCHEDULE_FIELD, SIZE_PERCENT_FIELD,
TEMPLATE_CONFIGURATION_FIELD, TREATMENT_DESCRIPTION_FIELD, TREATMENT_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final CustomDeliveryConfiguration customDeliveryConfiguration;
private final MessageConfiguration messageConfiguration;
private final Schedule schedule;
private final Integer sizePercent;
private final TemplateConfiguration templateConfiguration;
private final String treatmentDescription;
private final String treatmentName;
private WriteTreatmentResource(BuilderImpl builder) {
this.customDeliveryConfiguration = builder.customDeliveryConfiguration;
this.messageConfiguration = builder.messageConfiguration;
this.schedule = builder.schedule;
this.sizePercent = builder.sizePercent;
this.templateConfiguration = builder.templateConfiguration;
this.treatmentDescription = builder.treatmentDescription;
this.treatmentName = builder.treatmentName;
}
/**
*
* The delivery configuration settings for sending the treatment through a custom channel. This object is required
* if the MessageConfiguration object for the treatment specifies a CustomMessage object.
*
*
* @return The delivery configuration settings for sending the treatment through a custom channel. This object is
* required if the MessageConfiguration object for the treatment specifies a CustomMessage object.
*/
public final CustomDeliveryConfiguration customDeliveryConfiguration() {
return customDeliveryConfiguration;
}
/**
*
* The message configuration settings for the treatment.
*
*
* @return The message configuration settings for the treatment.
*/
public final MessageConfiguration messageConfiguration() {
return messageConfiguration;
}
/**
*
* The schedule settings for the treatment.
*
*
* @return The schedule settings for the treatment.
*/
public final Schedule schedule() {
return schedule;
}
/**
*
* The allocated percentage of users (segment members) to send the treatment to.
*
*
* @return The allocated percentage of users (segment members) to send the treatment to.
*/
public final Integer sizePercent() {
return sizePercent;
}
/**
*
* The message template to use for the treatment.
*
*
* @return The message template to use for the treatment.
*/
public final TemplateConfiguration templateConfiguration() {
return templateConfiguration;
}
/**
*
* A custom description of the treatment.
*
*
* @return A custom description of the treatment.
*/
public final String treatmentDescription() {
return treatmentDescription;
}
/**
*
* A custom name for the treatment.
*
*
* @return A custom name for the treatment.
*/
public final String treatmentName() {
return treatmentName;
}
@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(customDeliveryConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(messageConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(schedule());
hashCode = 31 * hashCode + Objects.hashCode(sizePercent());
hashCode = 31 * hashCode + Objects.hashCode(templateConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(treatmentDescription());
hashCode = 31 * hashCode + Objects.hashCode(treatmentName());
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 WriteTreatmentResource)) {
return false;
}
WriteTreatmentResource other = (WriteTreatmentResource) obj;
return Objects.equals(customDeliveryConfiguration(), other.customDeliveryConfiguration())
&& Objects.equals(messageConfiguration(), other.messageConfiguration())
&& Objects.equals(schedule(), other.schedule()) && Objects.equals(sizePercent(), other.sizePercent())
&& Objects.equals(templateConfiguration(), other.templateConfiguration())
&& Objects.equals(treatmentDescription(), other.treatmentDescription())
&& Objects.equals(treatmentName(), other.treatmentName());
}
/**
* 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("WriteTreatmentResource").add("CustomDeliveryConfiguration", customDeliveryConfiguration())
.add("MessageConfiguration", messageConfiguration()).add("Schedule", schedule())
.add("SizePercent", sizePercent()).add("TemplateConfiguration", templateConfiguration())
.add("TreatmentDescription", treatmentDescription()).add("TreatmentName", treatmentName()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CustomDeliveryConfiguration":
return Optional.ofNullable(clazz.cast(customDeliveryConfiguration()));
case "MessageConfiguration":
return Optional.ofNullable(clazz.cast(messageConfiguration()));
case "Schedule":
return Optional.ofNullable(clazz.cast(schedule()));
case "SizePercent":
return Optional.ofNullable(clazz.cast(sizePercent()));
case "TemplateConfiguration":
return Optional.ofNullable(clazz.cast(templateConfiguration()));
case "TreatmentDescription":
return Optional.ofNullable(clazz.cast(treatmentDescription()));
case "TreatmentName":
return Optional.ofNullable(clazz.cast(treatmentName()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function