All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.pinpoint.model.DefaultPushNotificationMessage 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

There is a newer version: 2.29.39
Show newest version
/*
 * 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.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.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Specifies the default settings and content for a push notification that's sent directly to an endpoint. *

*/ @Generated("software.amazon.awssdk:codegen") public final class DefaultPushNotificationMessage implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Action") .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).memberName("Body") .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) .memberName("Data") .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) .memberName("SilentPush").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) .memberName("Substitutions") .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).memberName("Title") .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).memberName("Url") .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 default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

    *
  • *
  • *

    * 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 default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

    *
  • *
  • *

    * 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 default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

      *
    • *
    • *

      * 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 default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

      *
    • *
    • *

      * 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 default body of the notification message. *

      * * @return The default body of the notification message. */ public final String body() { return body; } /** * For responses, this returns true if the service returned a value for the Data 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 hasData() { return data != null && !(data instanceof SdkAutoConstructMap); } /** *

      * The JSON data payload to use for the default push notification, if the notification is a silent push * notification. This payload is added to the data.pinpoint.jsonBody object of the notification. *

      *

      * 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 #hasData} method. *

      * * @return The JSON data payload to use for the default push notification, if the notification is a silent push * notification. This payload is added to the data.pinpoint.jsonBody object of the notification. */ public final Map data() { return data; } /** *

      * Specifies whether the default notification is a silent push notification, which is a push notification that * doesn't display on a recipient's device. Silent push notifications can be used for cases such as updating an * app's configuration or delivering messages to an in-app notification center. *

      * * @return Specifies whether the default notification is a silent push notification, which is a push notification * that doesn't display on a recipient's device. Silent push notifications can be used for cases such as * updating an app's configuration or delivering messages to an in-app notification center. */ public final Boolean silentPush() { return silentPush; } /** * For responses, this returns true if the service returned a value for the Substitutions 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 hasSubstitutions() { return substitutions != null && !(substitutions instanceof SdkAutoConstructMap); } /** *

      * The default message variables to use in the notification message. You can override the default variables with * individual address variables. *

      *

      * 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 #hasSubstitutions} method. *

      * * @return The default message variables to use in the notification message. You can override the default variables * with individual address variables. */ public final Map> substitutions() { return substitutions; } /** *

      * The default title to display above the notification message on a recipient's device. *

      * * @return The default title to display above the notification message on a recipient's device. */ public final String title() { return title; } /** *

      * The default URL to open in a recipient's default mobile browser, if a recipient taps the push notification and * the value of the Action property is URL. *

      * * @return The default URL to open in a recipient's default mobile browser, if a recipient taps the push * notification 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 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(hasData() ? data() : null); hashCode = 31 * hashCode + Objects.hashCode(silentPush()); hashCode = 31 * hashCode + Objects.hashCode(hasSubstitutions() ? substitutions() : null); 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 DefaultPushNotificationMessage)) { return false; } DefaultPushNotificationMessage other = (DefaultPushNotificationMessage) obj; return Objects.equals(actionAsString(), other.actionAsString()) && Objects.equals(body(), other.body()) && hasData() == other.hasData() && Objects.equals(data(), other.data()) && Objects.equals(silentPush(), other.silentPush()) && hasSubstitutions() == other.hasSubstitutions() && 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 final String toString() { return ToString.builder("DefaultPushNotificationMessage").add("Action", actionAsString()).add("Body", body()) .add("Data", hasData() ? data() : null).add("SilentPush", silentPush()) .add("Substitutions", hasSubstitutions() ? substitutions() : null).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 "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 final 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 default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

        *
      • *
      • *

        * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

        *
      • *
      * * @param action * The default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

        *
      • *
      • *

        * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that * you specify. *

        *
      • * @see Action * @return Returns a reference to this object so that method calls can be chained together. * @see Action */ Builder action(String action); /** *

        * The default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

          *
        • *
        • *

          * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

          *
        • *
        * * @param action * The default action to occur if a recipient taps the push notification. 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 setting uses the * deep-linking features of the iOS and Android platforms. *

          *
        • *
        • *

          * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that * you specify. *

          *
        • * @see Action * @return Returns a reference to this object so that method calls can be chained together. * @see Action */ Builder action(Action action); /** *

          * The default body of the notification message. *

          * * @param body * The default body of the notification message. * @return Returns a reference to this object so that method calls can be chained together. */ Builder body(String body); /** *

          * The JSON data payload to use for the default push notification, if the notification is a silent push * notification. This payload is added to the data.pinpoint.jsonBody object of the notification. *

          * * @param data * The JSON data payload to use for the default push notification, if the notification is a silent push * notification. This payload is added to the data.pinpoint.jsonBody object of the notification. * @return Returns a reference to this object so that method calls can be chained together. */ Builder data(Map data); /** *

          * Specifies whether the default notification is a silent push notification, which is a push notification that * doesn't display on a recipient's device. Silent push notifications can be used for cases such as updating an * app's configuration or delivering messages to an in-app notification center. *

          * * @param silentPush * Specifies whether the default notification is a silent push notification, which is a push notification * that doesn't display on a recipient's device. Silent push notifications can be used for cases such as * updating an app's configuration or delivering messages to an in-app notification center. * @return Returns a reference to this object so that method calls can be chained together. */ Builder silentPush(Boolean silentPush); /** *

          * The default message variables to use in the notification message. You can override the default variables with * individual address variables. *

          * * @param substitutions * The default message variables to use in the notification message. You can override the default * variables with individual address variables. * @return Returns a reference to this object so that method calls can be chained together. */ Builder substitutions(Map> substitutions); /** *

          * The default title to display above the notification message on a recipient's device. *

          * * @param title * The default title to display above the notification message on a recipient's device. * @return Returns a reference to this object so that method calls can be chained together. */ Builder title(String title); /** *

          * The default URL to open in a recipient's default mobile browser, if a recipient taps the push notification * and the value of the Action property is URL. *

          * * @param url * The default URL to open in a recipient's default mobile browser, if a recipient taps the push * notification and the value of the Action property 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 getAction() { return action; } public final void setAction(String action) { this.action = action; } @Override public final Builder action(String action) { this.action = action; return this; } @Override public final Builder action(Action action) { this.action(action == null ? null : action.toString()); return this; } public final String getBody() { return body; } public final void setBody(String body) { this.body = body; } @Override public final Builder body(String body) { this.body = body; return this; } public final Map getData() { if (data instanceof SdkAutoConstructMap) { return null; } return data; } public final void setData(Map data) { this.data = MapOf__stringCopier.copy(data); } @Override public final Builder data(Map data) { this.data = MapOf__stringCopier.copy(data); return this; } public final Boolean getSilentPush() { return silentPush; } public final void setSilentPush(Boolean silentPush) { this.silentPush = silentPush; } @Override public final Builder silentPush(Boolean silentPush) { this.silentPush = silentPush; return this; } public final Map> getSubstitutions() { if (substitutions instanceof SdkAutoConstructMap) { return null; } return substitutions; } public final void setSubstitutions(Map> substitutions) { this.substitutions = MapOfListOf__stringCopier.copy(substitutions); } @Override public final Builder substitutions(Map> substitutions) { this.substitutions = MapOfListOf__stringCopier.copy(substitutions); return this; } public final String getTitle() { return title; } public final void setTitle(String title) { this.title = title; } @Override public final Builder title(String title) { this.title = title; return this; } public final String getUrl() { return url; } public final void setUrl(String url) { this.url = url; } @Override public final Builder url(String url) { this.url = url; return this; } @Override public DefaultPushNotificationMessage build() { return new DefaultPushNotificationMessage(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy