software.amazon.awssdk.services.pinpoint.model.ClosedDays 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.Collection;
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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The time when a journey will not send messages. QuietTime should be configured first and SendingSchedule should be
* set to true.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ClosedDays implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField> EMAIL_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EMAIL")
.getter(getter(ClosedDays::email))
.setter(setter(Builder::email))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EMAIL").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ClosedDaysRule::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> SMS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SMS")
.getter(getter(ClosedDays::sms))
.setter(setter(Builder::sms))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SMS").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ClosedDaysRule::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> PUSH_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("PUSH")
.getter(getter(ClosedDays::push))
.setter(setter(Builder::push))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PUSH").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ClosedDaysRule::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> VOICE_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("VOICE")
.getter(getter(ClosedDays::voice))
.setter(setter(Builder::voice))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VOICE").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ClosedDaysRule::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> CUSTOM_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("CUSTOM")
.getter(getter(ClosedDays::custom))
.setter(setter(Builder::custom))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CUSTOM").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ClosedDaysRule::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(EMAIL_FIELD, SMS_FIELD,
PUSH_FIELD, VOICE_FIELD, CUSTOM_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("EMAIL", EMAIL_FIELD);
put("SMS", SMS_FIELD);
put("PUSH", PUSH_FIELD);
put("VOICE", VOICE_FIELD);
put("CUSTOM", CUSTOM_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final List email;
private final List sms;
private final List push;
private final List voice;
private final List custom;
private ClosedDays(BuilderImpl builder) {
this.email = builder.email;
this.sms = builder.sms;
this.push = builder.push;
this.voice = builder.voice;
this.custom = builder.custom;
}
/**
* For responses, this returns true if the service returned a value for the EMAIL 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 hasEmail() {
return email != null && !(email instanceof SdkAutoConstructList);
}
/**
*
* Rules for the Email channel.
*
*
* 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 #hasEmail} method.
*
*
* @return Rules for the Email channel.
*/
public final List email() {
return email;
}
/**
* For responses, this returns true if the service returned a value for the SMS 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 hasSms() {
return sms != null && !(sms instanceof SdkAutoConstructList);
}
/**
*
* Rules for the SMS channel.
*
*
* 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 #hasSms} method.
*
*
* @return Rules for the SMS channel.
*/
public final List sms() {
return sms;
}
/**
* For responses, this returns true if the service returned a value for the PUSH 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 hasPush() {
return push != null && !(push instanceof SdkAutoConstructList);
}
/**
*
* Rules for the Push channel.
*
*
* 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 #hasPush} method.
*
*
* @return Rules for the Push channel.
*/
public final List push() {
return push;
}
/**
* For responses, this returns true if the service returned a value for the VOICE 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 hasVoice() {
return voice != null && !(voice instanceof SdkAutoConstructList);
}
/**
*
* Rules for the Voice channel.
*
*
* 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 #hasVoice} method.
*
*
* @return Rules for the Voice channel.
*/
public final List voice() {
return voice;
}
/**
* For responses, this returns true if the service returned a value for the CUSTOM 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 hasCustom() {
return custom != null && !(custom instanceof SdkAutoConstructList);
}
/**
*
* Rules for the Custom channel.
*
*
* 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 #hasCustom} method.
*
*
* @return Rules for the Custom channel.
*/
public final List custom() {
return custom;
}
@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(hasEmail() ? email() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasSms() ? sms() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasPush() ? push() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasVoice() ? voice() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasCustom() ? custom() : null);
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 ClosedDays)) {
return false;
}
ClosedDays other = (ClosedDays) obj;
return hasEmail() == other.hasEmail() && Objects.equals(email(), other.email()) && hasSms() == other.hasSms()
&& Objects.equals(sms(), other.sms()) && hasPush() == other.hasPush() && Objects.equals(push(), other.push())
&& hasVoice() == other.hasVoice() && Objects.equals(voice(), other.voice()) && hasCustom() == other.hasCustom()
&& Objects.equals(custom(), other.custom());
}
/**
* 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("ClosedDays").add("EMAIL", hasEmail() ? email() : null).add("SMS", hasSms() ? sms() : null)
.add("PUSH", hasPush() ? push() : null).add("VOICE", hasVoice() ? voice() : null)
.add("CUSTOM", hasCustom() ? custom() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "EMAIL":
return Optional.ofNullable(clazz.cast(email()));
case "SMS":
return Optional.ofNullable(clazz.cast(sms()));
case "PUSH":
return Optional.ofNullable(clazz.cast(push()));
case "VOICE":
return Optional.ofNullable(clazz.cast(voice()));
case "CUSTOM":
return Optional.ofNullable(clazz.cast(custom()));
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