software.amazon.awssdk.services.pinpoint.model.Schedule 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 schedule settings for a campaign.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Schedule implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EndTime").getter(getter(Schedule::endTime)).setter(setter(Builder::endTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndTime").build()).build();
private static final SdkField EVENT_FILTER_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("EventFilter")
.getter(getter(Schedule::eventFilter)).setter(setter(Builder::eventFilter)).constructor(CampaignEventFilter::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventFilter").build()).build();
private static final SdkField FREQUENCY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Frequency").getter(getter(Schedule::frequencyAsString)).setter(setter(Builder::frequency))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Frequency").build()).build();
private static final SdkField IS_LOCAL_TIME_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("IsLocalTime").getter(getter(Schedule::isLocalTime)).setter(setter(Builder::isLocalTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IsLocalTime").build()).build();
private static final SdkField QUIET_TIME_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("QuietTime").getter(getter(Schedule::quietTime)).setter(setter(Builder::quietTime))
.constructor(QuietTime::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QuietTime").build()).build();
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StartTime").getter(getter(Schedule::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();
private static final SdkField TIMEZONE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Timezone").getter(getter(Schedule::timezone)).setter(setter(Builder::timezone))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timezone").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(END_TIME_FIELD,
EVENT_FILTER_FIELD, FREQUENCY_FIELD, IS_LOCAL_TIME_FIELD, QUIET_TIME_FIELD, START_TIME_FIELD, TIMEZONE_FIELD));
private static final long serialVersionUID = 1L;
private final String endTime;
private final CampaignEventFilter eventFilter;
private final String frequency;
private final Boolean isLocalTime;
private final QuietTime quietTime;
private final String startTime;
private final String timezone;
private Schedule(BuilderImpl builder) {
this.endTime = builder.endTime;
this.eventFilter = builder.eventFilter;
this.frequency = builder.frequency;
this.isLocalTime = builder.isLocalTime;
this.quietTime = builder.quietTime;
this.startTime = builder.startTime;
this.timezone = builder.timezone;
}
/**
*
* The scheduled time, in ISO 8601 format, when the campaign ended or will end.
*
*
* @return The scheduled time, in ISO 8601 format, when the campaign ended or will end.
*/
public final String endTime() {
return endTime;
}
/**
*
* The type of event that causes the campaign to be sent, if the value of the Frequency property is EVENT.
*
*
* @return The type of event that causes the campaign to be sent, if the value of the Frequency property is EVENT.
*/
public final CampaignEventFilter eventFilter() {
return eventFilter;
}
/**
*
* Specifies how often the campaign is sent or whether the campaign is sent in response to a specific event.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #frequency} will
* return {@link Frequency#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #frequencyAsString}.
*
*
* @return Specifies how often the campaign is sent or whether the campaign is sent in response to a specific event.
* @see Frequency
*/
public final Frequency frequency() {
return Frequency.fromValue(frequency);
}
/**
*
* Specifies how often the campaign is sent or whether the campaign is sent in response to a specific event.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #frequency} will
* return {@link Frequency#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #frequencyAsString}.
*
*
* @return Specifies how often the campaign is sent or whether the campaign is sent in response to a specific event.
* @see Frequency
*/
public final String frequencyAsString() {
return frequency;
}
/**
*
* Specifies whether the start and end times for the campaign schedule use each recipient's local time. To base the
* schedule on each recipient's local time, set this value to true.
*
*
* @return Specifies whether the start and end times for the campaign schedule use each recipient's local time. To
* base the schedule on each recipient's local time, set this value to true.
*/
public final Boolean isLocalTime() {
return isLocalTime;
}
/**
*
* The default quiet time for the campaign. Quiet time is a specific time range when a campaign doesn't send
* messages to endpoints, if all the following conditions are met:
*
*
* -
*
* The EndpointDemographic.Timezone property of the endpoint is set to a valid value.
*
*
* -
*
* The current time in the endpoint's time zone is later than or equal to the time specified by the QuietTime.Start
* property for the campaign.
*
*
* -
*
* The current time in the endpoint's time zone is earlier than or equal to the time specified by the QuietTime.End
* property for the campaign.
*
*
*
*
* If any of the preceding conditions isn't met, the endpoint will receive messages from the campaign, even if quiet
* time is enabled.
*
*
* @return The default quiet time for the campaign. Quiet time is a specific time range when a campaign doesn't send
* messages to endpoints, if all the following conditions are met:
*
* -
*
* The EndpointDemographic.Timezone property of the endpoint is set to a valid value.
*
*
* -
*
* The current time in the endpoint's time zone is later than or equal to the time specified by the
* QuietTime.Start property for the campaign.
*
*
* -
*
* The current time in the endpoint's time zone is earlier than or equal to the time specified by the
* QuietTime.End property for the campaign.
*
*
*
*
* If any of the preceding conditions isn't met, the endpoint will receive messages from the campaign, even
* if quiet time is enabled.
*/
public final QuietTime quietTime() {
return quietTime;
}
/**
*
* The scheduled time when the campaign began or will begin. Valid values are: IMMEDIATE, to start the campaign
* immediately; or, a specific time in ISO 8601 format.
*
*
* @return The scheduled time when the campaign began or will begin. Valid values are: IMMEDIATE, to start the
* campaign immediately; or, a specific time in ISO 8601 format.
*/
public final String startTime() {
return startTime;
}
/**
*
* The starting UTC offset for the campaign schedule, if the value of the IsLocalTime property is true. Valid values
* are: UTC, UTC+01, UTC+02, UTC+03, UTC+03:30, UTC+04, UTC+04:30, UTC+05, UTC+05:30, UTC+05:45, UTC+06, UTC+06:30,
* UTC+07, UTC+08, UTC+09, UTC+09:30, UTC+10, UTC+10:30, UTC+11, UTC+12, UTC+13, UTC-02, UTC-03, UTC-04, UTC-05,
* UTC-06, UTC-07, UTC-08, UTC-09, UTC-10, and UTC-11.
*
*
* @return The starting UTC offset for the campaign schedule, if the value of the IsLocalTime property is true.
* Valid values are: UTC, UTC+01, UTC+02, UTC+03, UTC+03:30, UTC+04, UTC+04:30, UTC+05, UTC+05:30,
* UTC+05:45, UTC+06, UTC+06:30, UTC+07, UTC+08, UTC+09, UTC+09:30, UTC+10, UTC+10:30, UTC+11, UTC+12,
* UTC+13, UTC-02, UTC-03, UTC-04, UTC-05, UTC-06, UTC-07, UTC-08, UTC-09, UTC-10, and UTC-11.
*/
public final String timezone() {
return timezone;
}
@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(endTime());
hashCode = 31 * hashCode + Objects.hashCode(eventFilter());
hashCode = 31 * hashCode + Objects.hashCode(frequencyAsString());
hashCode = 31 * hashCode + Objects.hashCode(isLocalTime());
hashCode = 31 * hashCode + Objects.hashCode(quietTime());
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(timezone());
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 Schedule)) {
return false;
}
Schedule other = (Schedule) obj;
return Objects.equals(endTime(), other.endTime()) && Objects.equals(eventFilter(), other.eventFilter())
&& Objects.equals(frequencyAsString(), other.frequencyAsString())
&& Objects.equals(isLocalTime(), other.isLocalTime()) && Objects.equals(quietTime(), other.quietTime())
&& Objects.equals(startTime(), other.startTime()) && Objects.equals(timezone(), other.timezone());
}
/**
* 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("Schedule").add("EndTime", endTime()).add("EventFilter", eventFilter())
.add("Frequency", frequencyAsString()).add("IsLocalTime", isLocalTime()).add("QuietTime", quietTime())
.add("StartTime", startTime()).add("Timezone", timezone()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "EndTime":
return Optional.ofNullable(clazz.cast(endTime()));
case "EventFilter":
return Optional.ofNullable(clazz.cast(eventFilter()));
case "Frequency":
return Optional.ofNullable(clazz.cast(frequencyAsString()));
case "IsLocalTime":
return Optional.ofNullable(clazz.cast(isLocalTime()));
case "QuietTime":
return Optional.ofNullable(clazz.cast(quietTime()));
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "Timezone":
return Optional.ofNullable(clazz.cast(timezone()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function