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.pinpoint.model.MessageRequest Maven / Gradle / Ivy
Go to download
The AWS Java SDK for Amazon Pinpoint module holds the client classes that are used for communicating
with Amazon Pinpoint Service
/*
* Copyright 2014-2019 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.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.utils.CollectionUtils;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Specifies the configuration and other settings for a message.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class MessageRequest implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField> ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(MessageRequest::addresses))
.setter(setter(Builder::addresses))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Addresses").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AddressConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField> CONTEXT_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(MessageRequest::context))
.setter(setter(Builder::context))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Context").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> ENDPOINTS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(MessageRequest::endpoints))
.setter(setter(Builder::endpoints))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Endpoints").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(EndpointSendConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField MESSAGE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(MessageRequest::messageConfiguration))
.setter(setter(Builder::messageConfiguration)).constructor(DirectMessageConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MessageConfiguration").build())
.build();
private static final SdkField TEMPLATE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(MessageRequest::templateConfiguration))
.setter(setter(Builder::templateConfiguration)).constructor(TemplateConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateConfiguration").build())
.build();
private static final SdkField TRACE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(MessageRequest::traceId)).setter(setter(Builder::traceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TraceId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ADDRESSES_FIELD,
CONTEXT_FIELD, ENDPOINTS_FIELD, MESSAGE_CONFIGURATION_FIELD, TEMPLATE_CONFIGURATION_FIELD, TRACE_ID_FIELD));
private static final long serialVersionUID = 1L;
private final Map addresses;
private final Map context;
private final Map endpoints;
private final DirectMessageConfiguration messageConfiguration;
private final TemplateConfiguration templateConfiguration;
private final String traceId;
private MessageRequest(BuilderImpl builder) {
this.addresses = builder.addresses;
this.context = builder.context;
this.endpoints = builder.endpoints;
this.messageConfiguration = builder.messageConfiguration;
this.templateConfiguration = builder.templateConfiguration;
this.traceId = builder.traceId;
}
/**
*
* A map of key-value pairs, where each key is an address and each value is an AddressConfiguration object. An
* address can be a push notification token, a phone number, or an email address. You can use an
* AddressConfiguration object to tailor the message for an address by specifying settings such as content overrides
* and message variables.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A map of key-value pairs, where each key is an address and each value is an AddressConfiguration object.
* An address can be a push notification token, a phone number, or an email address. You can use an
* AddressConfiguration object to tailor the message for an address by specifying settings such as content
* overrides and message variables.
*/
public Map addresses() {
return addresses;
}
/**
*
* A map of custom attributes to attach to the message. For a push notification, this payload is added to the
* data.pinpoint object. For an email or text message, this payload is added to email/SMS delivery receipt event
* attributes.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A map of custom attributes to attach to the message. For a push notification, this payload is added to
* the data.pinpoint object. For an email or text message, this payload is added to email/SMS delivery
* receipt event attributes.
*/
public Map context() {
return context;
}
/**
*
* A map of key-value pairs, where each key is an endpoint ID and each value is an EndpointSendConfiguration object.
* You can use an EndpointSendConfiguration object to tailor the message for an endpoint by specifying settings such
* as content overrides and message variables.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A map of key-value pairs, where each key is an endpoint ID and each value is an EndpointSendConfiguration
* object. You can use an EndpointSendConfiguration object to tailor the message for an endpoint by
* specifying settings such as content overrides and message variables.
*/
public Map endpoints() {
return endpoints;
}
/**
*
* The settings and content for the default message and any default messages that you defined for specific channels.
*
*
* @return The settings and content for the default message and any default messages that you defined for specific
* channels.
*/
public DirectMessageConfiguration messageConfiguration() {
return messageConfiguration;
}
/**
*
* The message template to use for the message.
*
*
* @return The message template to use for the message.
*/
public TemplateConfiguration templateConfiguration() {
return templateConfiguration;
}
/**
*
* The unique identifier for tracing the message. This identifier is visible to message recipients.
*
*
* @return The unique identifier for tracing the message. This identifier is visible to message recipients.
*/
public String traceId() {
return traceId;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(addresses());
hashCode = 31 * hashCode + Objects.hashCode(context());
hashCode = 31 * hashCode + Objects.hashCode(endpoints());
hashCode = 31 * hashCode + Objects.hashCode(messageConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(templateConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(traceId());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof MessageRequest)) {
return false;
}
MessageRequest other = (MessageRequest) obj;
return Objects.equals(addresses(), other.addresses()) && Objects.equals(context(), other.context())
&& Objects.equals(endpoints(), other.endpoints())
&& Objects.equals(messageConfiguration(), other.messageConfiguration())
&& Objects.equals(templateConfiguration(), other.templateConfiguration())
&& Objects.equals(traceId(), other.traceId());
}
/**
* 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 String toString() {
return ToString.builder("MessageRequest").add("Addresses", addresses()).add("Context", context())
.add("Endpoints", endpoints()).add("MessageConfiguration", messageConfiguration())
.add("TemplateConfiguration", templateConfiguration()).add("TraceId", traceId()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Addresses":
return Optional.ofNullable(clazz.cast(addresses()));
case "Context":
return Optional.ofNullable(clazz.cast(context()));
case "Endpoints":
return Optional.ofNullable(clazz.cast(endpoints()));
case "MessageConfiguration":
return Optional.ofNullable(clazz.cast(messageConfiguration()));
case "TemplateConfiguration":
return Optional.ofNullable(clazz.cast(templateConfiguration()));
case "TraceId":
return Optional.ofNullable(clazz.cast(traceId()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((MessageRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* A map of key-value pairs, where each key is an address and each value is an AddressConfiguration object. An
* address can be a push notification token, a phone number, or an email address. You can use an
* AddressConfiguration object to tailor the message for an address by specifying settings such as content
* overrides and message variables.
*
*
* @param addresses
* A map of key-value pairs, where each key is an address and each value is an AddressConfiguration
* object. An address can be a push notification token, a phone number, or an email address. You can use
* an AddressConfiguration object to tailor the message for an address by specifying settings such as
* content overrides and message variables.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder addresses(Map addresses);
/**
*
* A map of custom attributes to attach to the message. For a push notification, this payload is added to the
* data.pinpoint object. For an email or text message, this payload is added to email/SMS delivery receipt event
* attributes.
*
*
* @param context
* A map of custom attributes to attach to the message. For a push notification, this payload is added to
* the data.pinpoint object. For an email or text message, this payload is added to email/SMS delivery
* receipt event attributes.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder context(Map context);
/**
*
* A map of key-value pairs, where each key is an endpoint ID and each value is an EndpointSendConfiguration
* object. You can use an EndpointSendConfiguration object to tailor the message for an endpoint by specifying
* settings such as content overrides and message variables.
*
*
* @param endpoints
* A map of key-value pairs, where each key is an endpoint ID and each value is an
* EndpointSendConfiguration object. You can use an EndpointSendConfiguration object to tailor the
* message for an endpoint by specifying settings such as content overrides and message variables.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder endpoints(Map endpoints);
/**
*
* The settings and content for the default message and any default messages that you defined for specific
* channels.
*
*
* @param messageConfiguration
* The settings and content for the default message and any default messages that you defined for
* specific channels.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder messageConfiguration(DirectMessageConfiguration messageConfiguration);
/**
*
* The settings and content for the default message and any default messages that you defined for specific
* channels.
*
* This is a convenience that creates an instance of the {@link DirectMessageConfiguration.Builder} avoiding the
* need to create one manually via {@link DirectMessageConfiguration#builder()}.
*
* When the {@link Consumer} completes, {@link DirectMessageConfiguration.Builder#build()} is called immediately
* and its result is passed to {@link #messageConfiguration(DirectMessageConfiguration)}.
*
* @param messageConfiguration
* a consumer that will call methods on {@link DirectMessageConfiguration.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #messageConfiguration(DirectMessageConfiguration)
*/
default Builder messageConfiguration(Consumer messageConfiguration) {
return messageConfiguration(DirectMessageConfiguration.builder().applyMutation(messageConfiguration).build());
}
/**
*
* The message template to use for the message.
*
*
* @param templateConfiguration
* The message template to use for the message.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder templateConfiguration(TemplateConfiguration templateConfiguration);
/**
*
* The message template to use for the message.
*
* This is a convenience that creates an instance of the {@link TemplateConfiguration.Builder} avoiding the need
* to create one manually via {@link TemplateConfiguration#builder()}.
*
* When the {@link Consumer} completes, {@link TemplateConfiguration.Builder#build()} is called immediately and
* its result is passed to {@link #templateConfiguration(TemplateConfiguration)}.
*
* @param templateConfiguration
* a consumer that will call methods on {@link TemplateConfiguration.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #templateConfiguration(TemplateConfiguration)
*/
default Builder templateConfiguration(Consumer templateConfiguration) {
return templateConfiguration(TemplateConfiguration.builder().applyMutation(templateConfiguration).build());
}
/**
*
* The unique identifier for tracing the message. This identifier is visible to message recipients.
*
*
* @param traceId
* The unique identifier for tracing the message. This identifier is visible to message recipients.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder traceId(String traceId);
}
static final class BuilderImpl implements Builder {
private Map addresses = DefaultSdkAutoConstructMap.getInstance();
private Map context = DefaultSdkAutoConstructMap.getInstance();
private Map endpoints = DefaultSdkAutoConstructMap.getInstance();
private DirectMessageConfiguration messageConfiguration;
private TemplateConfiguration templateConfiguration;
private String traceId;
private BuilderImpl() {
}
private BuilderImpl(MessageRequest model) {
addresses(model.addresses);
context(model.context);
endpoints(model.endpoints);
messageConfiguration(model.messageConfiguration);
templateConfiguration(model.templateConfiguration);
traceId(model.traceId);
}
public final Map getAddresses() {
return addresses != null ? CollectionUtils.mapValues(addresses, AddressConfiguration::toBuilder) : null;
}
@Override
public final Builder addresses(Map addresses) {
this.addresses = MapOfAddressConfigurationCopier.copy(addresses);
return this;
}
public final void setAddresses(Map addresses) {
this.addresses = MapOfAddressConfigurationCopier.copyFromBuilder(addresses);
}
public final Map getContext() {
return context;
}
@Override
public final Builder context(Map context) {
this.context = MapOf__stringCopier.copy(context);
return this;
}
public final void setContext(Map context) {
this.context = MapOf__stringCopier.copy(context);
}
public final Map getEndpoints() {
return endpoints != null ? CollectionUtils.mapValues(endpoints, EndpointSendConfiguration::toBuilder) : null;
}
@Override
public final Builder endpoints(Map endpoints) {
this.endpoints = MapOfEndpointSendConfigurationCopier.copy(endpoints);
return this;
}
public final void setEndpoints(Map endpoints) {
this.endpoints = MapOfEndpointSendConfigurationCopier.copyFromBuilder(endpoints);
}
public final DirectMessageConfiguration.Builder getMessageConfiguration() {
return messageConfiguration != null ? messageConfiguration.toBuilder() : null;
}
@Override
public final Builder messageConfiguration(DirectMessageConfiguration messageConfiguration) {
this.messageConfiguration = messageConfiguration;
return this;
}
public final void setMessageConfiguration(DirectMessageConfiguration.BuilderImpl messageConfiguration) {
this.messageConfiguration = messageConfiguration != null ? messageConfiguration.build() : null;
}
public final TemplateConfiguration.Builder getTemplateConfiguration() {
return templateConfiguration != null ? templateConfiguration.toBuilder() : null;
}
@Override
public final Builder templateConfiguration(TemplateConfiguration templateConfiguration) {
this.templateConfiguration = templateConfiguration;
return this;
}
public final void setTemplateConfiguration(TemplateConfiguration.BuilderImpl templateConfiguration) {
this.templateConfiguration = templateConfiguration != null ? templateConfiguration.build() : null;
}
public final String getTraceId() {
return traceId;
}
@Override
public final Builder traceId(String traceId) {
this.traceId = traceId;
return this;
}
public final void setTraceId(String traceId) {
this.traceId = traceId;
}
@Override
public MessageRequest build() {
return new MessageRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}