software.amazon.awssdk.services.pinpoint.model.AndroidPushNotificationTemplate 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.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 channel-specific content and settings for a message template that can be used in push notifications that
* are sent through the ADM (Amazon Device Messaging), Baidu (Baidu Cloud Push), or GCM (Firebase Cloud Messaging,
* formerly Google Cloud Messaging) channel.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AndroidPushNotificationTemplate implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Action")
.getter(getter(AndroidPushNotificationTemplate::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).memberName("Body")
.getter(getter(AndroidPushNotificationTemplate::body)).setter(setter(Builder::body))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Body").build()).build();
private static final SdkField IMAGE_ICON_URL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ImageIconUrl").getter(getter(AndroidPushNotificationTemplate::imageIconUrl))
.setter(setter(Builder::imageIconUrl))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImageIconUrl").build()).build();
private static final SdkField IMAGE_URL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ImageUrl").getter(getter(AndroidPushNotificationTemplate::imageUrl)).setter(setter(Builder::imageUrl))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImageUrl").build()).build();
private static final SdkField RAW_CONTENT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RawContent").getter(getter(AndroidPushNotificationTemplate::rawContent))
.setter(setter(Builder::rawContent))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RawContent").build()).build();
private static final SdkField SMALL_IMAGE_ICON_URL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SmallImageIconUrl").getter(getter(AndroidPushNotificationTemplate::smallImageIconUrl))
.setter(setter(Builder::smallImageIconUrl))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SmallImageIconUrl").build()).build();
private static final SdkField SOUND_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Sound")
.getter(getter(AndroidPushNotificationTemplate::sound)).setter(setter(Builder::sound))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Sound").build()).build();
private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Title")
.getter(getter(AndroidPushNotificationTemplate::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).memberName("Url")
.getter(getter(AndroidPushNotificationTemplate::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,
IMAGE_ICON_URL_FIELD, IMAGE_URL_FIELD, RAW_CONTENT_FIELD, SMALL_IMAGE_ICON_URL_FIELD, SOUND_FIELD, TITLE_FIELD,
URL_FIELD));
private static final long serialVersionUID = 1L;
private final String action;
private final String body;
private final String imageIconUrl;
private final String imageUrl;
private final String rawContent;
private final String smallImageIconUrl;
private final String sound;
private final String title;
private final String url;
private AndroidPushNotificationTemplate(BuilderImpl builder) {
this.action = builder.action;
this.body = builder.body;
this.imageIconUrl = builder.imageIconUrl;
this.imageUrl = builder.imageUrl;
this.rawContent = builder.rawContent;
this.smallImageIconUrl = builder.smallImageIconUrl;
this.sound = builder.sound;
this.title = builder.title;
this.url = builder.url;
}
/**
*
* The action to occur if a recipient taps a push notification that's based on the message template. Valid values
* are:
*
*
* -
*
* OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the default
* action.
*
*
* -
*
* DEEP_LINK - Your app opens and displays a designated user interface in the app. This action uses the deep-linking
* features of the Android platform.
*
*
* -
*
* URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you
* specify.
*
*
*
*
* 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 to occur if a recipient taps a push notification that's based on the message template. Valid
* values are:
*
* -
*
* OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the
* default action.
*
*
* -
*
* DEEP_LINK - Your app opens and displays a designated user interface in the app. This action uses the
* deep-linking features of the Android platform.
*
*
* -
*
* URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you
* specify.
*
*
* @see Action
*/
public final Action action() {
return Action.fromValue(action);
}
/**
*
* The action to occur if a recipient taps a push notification that's based on the message template. Valid values
* are:
*
*
* -
*
* OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the default
* action.
*
*
* -
*
* DEEP_LINK - Your app opens and displays a designated user interface in the app. This action uses the deep-linking
* features of the Android platform.
*
*
* -
*
* URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you
* specify.
*
*
*
*
* 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 to occur if a recipient taps a push notification that's based on the message template. Valid
* values are:
*
* -
*
* OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the
* default action.
*
*
* -
*
* DEEP_LINK - Your app opens and displays a designated user interface in the app. This action uses the
* deep-linking features of the Android platform.
*
*
* -
*
* URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you
* specify.
*
*
* @see Action
*/
public final String actionAsString() {
return action;
}
/**
*
* The message body to use in a push notification that's based on the message template.
*
*
* @return The message body to use in a push notification that's based on the message template.
*/
public final String body() {
return body;
}
/**
*
* The URL of the large icon image to display in the content view of a push notification that's based on the message
* template.
*
*
* @return The URL of the large icon image to display in the content view of a push notification that's based on the
* message template.
*/
public final String imageIconUrl() {
return imageIconUrl;
}
/**
*
* The URL of an image to display in a push notification that's based on the message template.
*
*
* @return The URL of an image to display in a push notification that's based on the message template.
*/
public final String imageUrl() {
return imageUrl;
}
/**
*
* The raw, JSON-formatted string to use as the payload for a push notification that's based on the message
* template. If specified, this value overrides all other content for the message template.
*
*
* @return The raw, JSON-formatted string to use as the payload for a push notification that's based on the message
* template. If specified, this value overrides all other content for the message template.
*/
public final String rawContent() {
return rawContent;
}
/**
*
* The URL of the small icon image to display in the status bar and the content view of a push notification that's
* based on the message template.
*
*
* @return The URL of the small icon image to display in the status bar and the content view of a push notification
* that's based on the message template.
*/
public final String smallImageIconUrl() {
return smallImageIconUrl;
}
/**
*
* The sound to play when a recipient receives a push notification that's based on the message template. You can use
* the default stream or specify the file name of a sound resource that's bundled in your app. On an Android
* platform, the sound file must reside in /res/raw/.
*
*
* @return The sound to play when a recipient receives a push notification that's based on the message template. You
* can use the default stream or specify the file name of a sound resource that's bundled in your app. On an
* Android platform, the sound file must reside in /res/raw/.
*/
public final String sound() {
return sound;
}
/**
*
* The title to use in a push notification that's based on the message template. This title appears above the
* notification message on a recipient's device.
*
*
* @return The title to use in a push notification that's based on the message template. This title appears above
* the notification message on a recipient's device.
*/
public final String title() {
return title;
}
/**
*
* The URL to open in a recipient's default mobile browser, if a recipient taps a push notification that's based on
* the message template and the value of the Action property is URL.
*
*
* @return The URL to open in a recipient's default mobile browser, if a recipient taps a push notification that's
* based on the message template and the value of the Action property is URL.
*/
public final 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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(actionAsString());
hashCode = 31 * hashCode + Objects.hashCode(body());
hashCode = 31 * hashCode + Objects.hashCode(imageIconUrl());
hashCode = 31 * hashCode + Objects.hashCode(imageUrl());
hashCode = 31 * hashCode + Objects.hashCode(rawContent());
hashCode = 31 * hashCode + Objects.hashCode(smallImageIconUrl());
hashCode = 31 * hashCode + Objects.hashCode(sound());
hashCode = 31 * hashCode + Objects.hashCode(title());
hashCode = 31 * hashCode + Objects.hashCode(url());
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 AndroidPushNotificationTemplate)) {
return false;
}
AndroidPushNotificationTemplate other = (AndroidPushNotificationTemplate) obj;
return Objects.equals(actionAsString(), other.actionAsString()) && Objects.equals(body(), other.body())
&& Objects.equals(imageIconUrl(), other.imageIconUrl()) && Objects.equals(imageUrl(), other.imageUrl())
&& Objects.equals(rawContent(), other.rawContent())
&& Objects.equals(smallImageIconUrl(), other.smallImageIconUrl()) && Objects.equals(sound(), other.sound())
&& 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 final String toString() {
return ToString.builder("AndroidPushNotificationTemplate").add("Action", actionAsString()).add("Body", body())
.add("ImageIconUrl", imageIconUrl()).add("ImageUrl", imageUrl()).add("RawContent", rawContent())
.add("SmallImageIconUrl", smallImageIconUrl()).add("Sound", sound()).add("Title", title()).add("Url", url())
.build();
}
public final 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 "ImageIconUrl":
return Optional.ofNullable(clazz.cast(imageIconUrl()));
case "ImageUrl":
return Optional.ofNullable(clazz.cast(imageUrl()));
case "RawContent":
return Optional.ofNullable(clazz.cast(rawContent()));
case "SmallImageIconUrl":
return Optional.ofNullable(clazz.cast(smallImageIconUrl()));
case "Sound":
return Optional.ofNullable(clazz.cast(sound()));
case "Title":
return Optional.ofNullable(clazz.cast(title()));
case "Url":
return Optional.ofNullable(clazz.cast(url()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function