All Downloads are FREE. Search and download functionalities are using the official Maven repository.
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.DefaultPushNotificationMessage Maven / Gradle / Ivy
/*
* 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.Collection;
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.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.ListTrait;
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.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
* Default Push Notification Message.
*/
@Generated("software.amazon.awssdk:codegen")
public final class DefaultPushNotificationMessage implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(DefaultPushNotificationMessage::actionAsString)).setter(setter(Builder::action))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Action").build()).build();
private static final SdkField BODY_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(DefaultPushNotificationMessage::body)).setter(setter(Builder::body))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Body").build()).build();
private static final SdkField> DATA_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(DefaultPushNotificationMessage::data))
.setter(setter(Builder::data))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Data").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 SILENT_PUSH_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.getter(getter(DefaultPushNotificationMessage::silentPush)).setter(setter(Builder::silentPush))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SilentPush").build()).build();
private static final SdkField>> SUBSTITUTIONS_FIELD = SdkField
.>> builder(MarshallingType.MAP)
.getter(getter(DefaultPushNotificationMessage::substitutions))
.setter(setter(Builder::substitutions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Substitutions").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField.> builder(MarshallingType.LIST)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder()
.location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build())
.build()).build()).build()).build();
private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(DefaultPushNotificationMessage::title)).setter(setter(Builder::title))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Title").build()).build();
private static final SdkField URL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(DefaultPushNotificationMessage::url)).setter(setter(Builder::url))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Url").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACTION_FIELD, BODY_FIELD,
DATA_FIELD, SILENT_PUSH_FIELD, SUBSTITUTIONS_FIELD, TITLE_FIELD, URL_FIELD));
private static final long serialVersionUID = 1L;
private final String action;
private final String body;
private final Map data;
private final Boolean silentPush;
private final Map> substitutions;
private final String title;
private final String url;
private DefaultPushNotificationMessage(BuilderImpl builder) {
this.action = builder.action;
this.body = builder.body;
this.data = builder.data;
this.silentPush = builder.silentPush;
this.substitutions = builder.substitutions;
this.title = builder.title;
this.url = builder.url;
}
/**
* The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your app
* launches, or it becomes the foreground app if it has been sent to the background. This is the default action.
* DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display a designated user
* interface within the app. URL - The default mobile browser on the user's device launches and opens a web page at
* the URL you specify. Possible values include: OPEN_APP | DEEP_LINK | URL
*
* If the service returns an enum value that is not available in the current SDK version, {@link #action} will
* return {@link Action#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #actionAsString}.
*
*
* @return The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your
* app launches, or it becomes the foreground app if it has been sent to the background. This is the default
* action. DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display a
* designated user interface within the app. URL - The default mobile browser on the user's device launches
* and opens a web page at the URL you specify. Possible values include: OPEN_APP | DEEP_LINK | URL
* @see Action
*/
public Action action() {
return Action.fromValue(action);
}
/**
* The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your app
* launches, or it becomes the foreground app if it has been sent to the background. This is the default action.
* DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display a designated user
* interface within the app. URL - The default mobile browser on the user's device launches and opens a web page at
* the URL you specify. Possible values include: OPEN_APP | DEEP_LINK | URL
*
* If the service returns an enum value that is not available in the current SDK version, {@link #action} will
* return {@link Action#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #actionAsString}.
*
*
* @return The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your
* app launches, or it becomes the foreground app if it has been sent to the background. This is the default
* action. DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display a
* designated user interface within the app. URL - The default mobile browser on the user's device launches
* and opens a web page at the URL you specify. Possible values include: OPEN_APP | DEEP_LINK | URL
* @see Action
*/
public String actionAsString() {
return action;
}
/**
* The message body of the notification.
*
* @return The message body of the notification.
*/
public String body() {
return body;
}
/**
* The data payload used for a silent push. This payload is added to the notifications' data.pinpoint.jsonBody'
* object
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The data payload used for a silent push. This payload is added to the notifications'
* data.pinpoint.jsonBody' object
*/
public Map data() {
return data;
}
/**
* Indicates if the message should display on the recipient's device. You can use silent pushes for remote
* configuration or to deliver messages to in-app notification centers.
*
* @return Indicates if the message should display on the recipient's device. You can use silent pushes for remote
* configuration or to deliver messages to in-app notification centers.
*/
public Boolean silentPush() {
return silentPush;
}
/**
* Default message substitutions. Can be overridden by individual address substitutions.
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Default message substitutions. Can be overridden by individual address substitutions.
*/
public Map> substitutions() {
return substitutions;
}
/**
* The message title that displays above the message on the user's device.
*
* @return The message title that displays above the message on the user's device.
*/
public String title() {
return title;
}
/**
* The URL to open in the user's mobile browser. Used if the value for Action is URL.
*
* @return The URL to open in the user's mobile browser. Used if the value for Action is URL.
*/
public String url() {
return url;
}
@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(actionAsString());
hashCode = 31 * hashCode + Objects.hashCode(body());
hashCode = 31 * hashCode + Objects.hashCode(data());
hashCode = 31 * hashCode + Objects.hashCode(silentPush());
hashCode = 31 * hashCode + Objects.hashCode(substitutions());
hashCode = 31 * hashCode + Objects.hashCode(title());
hashCode = 31 * hashCode + Objects.hashCode(url());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DefaultPushNotificationMessage)) {
return false;
}
DefaultPushNotificationMessage other = (DefaultPushNotificationMessage) obj;
return Objects.equals(actionAsString(), other.actionAsString()) && Objects.equals(body(), other.body())
&& Objects.equals(data(), other.data()) && Objects.equals(silentPush(), other.silentPush())
&& Objects.equals(substitutions(), other.substitutions()) && Objects.equals(title(), other.title())
&& Objects.equals(url(), other.url());
}
/**
* 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("DefaultPushNotificationMessage").add("Action", actionAsString()).add("Body", body())
.add("Data", data()).add("SilentPush", silentPush()).add("Substitutions", substitutions()).add("Title", title())
.add("Url", url()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Action":
return Optional.ofNullable(clazz.cast(actionAsString()));
case "Body":
return Optional.ofNullable(clazz.cast(body()));
case "Data":
return Optional.ofNullable(clazz.cast(data()));
case "SilentPush":
return Optional.ofNullable(clazz.cast(silentPush()));
case "Substitutions":
return Optional.ofNullable(clazz.cast(substitutions()));
case "Title":
return Optional.ofNullable(clazz.cast(title()));
case "Url":
return Optional.ofNullable(clazz.cast(url()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((DefaultPushNotificationMessage) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
* The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your app
* launches, or it becomes the foreground app if it has been sent to the background. This is the default action.
* DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display a designated user
* interface within the app. URL - The default mobile browser on the user's device launches and opens a web page
* at the URL you specify. Possible values include: OPEN_APP | DEEP_LINK | URL
*
* @param action
* The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your
* app launches, or it becomes the foreground app if it has been sent to the background. This is the
* default action. DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display
* a designated user interface within the app. URL - The default mobile browser on the user's device
* launches and opens a web page at the URL you specify. Possible values include: OPEN_APP | DEEP_LINK |
* URL
* @see Action
* @return Returns a reference to this object so that method calls can be chained together.
* @see Action
*/
Builder action(String action);
/**
* The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your app
* launches, or it becomes the foreground app if it has been sent to the background. This is the default action.
* DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display a designated user
* interface within the app. URL - The default mobile browser on the user's device launches and opens a web page
* at the URL you specify. Possible values include: OPEN_APP | DEEP_LINK | URL
*
* @param action
* The action that occurs if the user taps a push notification delivered by the campaign: OPEN_APP - Your
* app launches, or it becomes the foreground app if it has been sent to the background. This is the
* default action. DEEP_LINK - Uses deep linking features in iOS and Android to open your app and display
* a designated user interface within the app. URL - The default mobile browser on the user's device
* launches and opens a web page at the URL you specify. Possible values include: OPEN_APP | DEEP_LINK |
* URL
* @see Action
* @return Returns a reference to this object so that method calls can be chained together.
* @see Action
*/
Builder action(Action action);
/**
* The message body of the notification.
*
* @param body
* The message body of the notification.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder body(String body);
/**
* The data payload used for a silent push. This payload is added to the notifications' data.pinpoint.jsonBody'
* object
*
* @param data
* The data payload used for a silent push. This payload is added to the notifications'
* data.pinpoint.jsonBody' object
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder data(Map data);
/**
* Indicates if the message should display on the recipient's device. You can use silent pushes for remote
* configuration or to deliver messages to in-app notification centers.
*
* @param silentPush
* Indicates if the message should display on the recipient's device. You can use silent pushes for
* remote configuration or to deliver messages to in-app notification centers.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder silentPush(Boolean silentPush);
/**
* Default message substitutions. Can be overridden by individual address substitutions.
*
* @param substitutions
* Default message substitutions. Can be overridden by individual address substitutions.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder substitutions(Map> substitutions);
/**
* The message title that displays above the message on the user's device.
*
* @param title
* The message title that displays above the message on the user's device.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder title(String title);
/**
* The URL to open in the user's mobile browser. Used if the value for Action is URL.
*
* @param url
* The URL to open in the user's mobile browser. Used if the value for Action is URL.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder url(String url);
}
static final class BuilderImpl implements Builder {
private String action;
private String body;
private Map data = DefaultSdkAutoConstructMap.getInstance();
private Boolean silentPush;
private Map> substitutions = DefaultSdkAutoConstructMap.getInstance();
private String title;
private String url;
private BuilderImpl() {
}
private BuilderImpl(DefaultPushNotificationMessage model) {
action(model.action);
body(model.body);
data(model.data);
silentPush(model.silentPush);
substitutions(model.substitutions);
title(model.title);
url(model.url);
}
public final String getActionAsString() {
return action;
}
@Override
public final Builder action(String action) {
this.action = action;
return this;
}
@Override
public final Builder action(Action action) {
this.action(action.toString());
return this;
}
public final void setAction(String action) {
this.action = action;
}
public final String getBody() {
return body;
}
@Override
public final Builder body(String body) {
this.body = body;
return this;
}
public final void setBody(String body) {
this.body = body;
}
public final Map getData() {
return data;
}
@Override
public final Builder data(Map data) {
this.data = MapOf__stringCopier.copy(data);
return this;
}
public final void setData(Map data) {
this.data = MapOf__stringCopier.copy(data);
}
public final Boolean getSilentPush() {
return silentPush;
}
@Override
public final Builder silentPush(Boolean silentPush) {
this.silentPush = silentPush;
return this;
}
public final void setSilentPush(Boolean silentPush) {
this.silentPush = silentPush;
}
public final Map> getSubstitutions() {
return substitutions;
}
@Override
public final Builder substitutions(Map> substitutions) {
this.substitutions = MapOfListOf__stringCopier.copy(substitutions);
return this;
}
public final void setSubstitutions(Map> substitutions) {
this.substitutions = MapOfListOf__stringCopier.copy(substitutions);
}
public final String getTitle() {
return title;
}
@Override
public final Builder title(String title) {
this.title = title;
return this;
}
public final void setTitle(String title) {
this.title = title;
}
public final String getUrl() {
return url;
}
@Override
public final Builder url(String url) {
this.url = url;
return this;
}
public final void setUrl(String url) {
this.url = url;
}
@Override
public DefaultPushNotificationMessage build() {
return new DefaultPushNotificationMessage(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}