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

software.amazon.awssdk.services.pinpoint.model.Event 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.28.4
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.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.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Specifies information about an event that reports data to Amazon Pinpoint. *

*/ @Generated("software.amazon.awssdk:codegen") public final class Event implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField APP_PACKAGE_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("AppPackageName").getter(getter(Event::appPackageName)).setter(setter(Builder::appPackageName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AppPackageName").build()).build(); private static final SdkField APP_TITLE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("AppTitle").getter(getter(Event::appTitle)).setter(setter(Builder::appTitle)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AppTitle").build()).build(); private static final SdkField APP_VERSION_CODE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("AppVersionCode").getter(getter(Event::appVersionCode)).setter(setter(Builder::appVersionCode)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AppVersionCode").build()).build(); private static final SdkField> ATTRIBUTES_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("Attributes") .getter(getter(Event::attributes)) .setter(setter(Builder::attributes)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Attributes").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 CLIENT_SDK_VERSION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ClientSdkVersion").getter(getter(Event::clientSdkVersion)).setter(setter(Builder::clientSdkVersion)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientSdkVersion").build()).build(); private static final SdkField EVENT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("EventType").getter(getter(Event::eventType)).setter(setter(Builder::eventType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventType").build()).build(); private static final SdkField> METRICS_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("Metrics") .getter(getter(Event::metrics)) .setter(setter(Builder::metrics)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metrics").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.DOUBLE) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField SDK_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("SdkName").getter(getter(Event::sdkName)).setter(setter(Builder::sdkName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SdkName").build()).build(); private static final SdkField SESSION_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("Session").getter(getter(Event::session)).setter(setter(Builder::session)).constructor(Session::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Session").build()).build(); private static final SdkField TIMESTAMP_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("Timestamp").getter(getter(Event::timestamp)).setter(setter(Builder::timestamp)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timestamp").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(APP_PACKAGE_NAME_FIELD, APP_TITLE_FIELD, APP_VERSION_CODE_FIELD, ATTRIBUTES_FIELD, CLIENT_SDK_VERSION_FIELD, EVENT_TYPE_FIELD, METRICS_FIELD, SDK_NAME_FIELD, SESSION_FIELD, TIMESTAMP_FIELD)); private static final long serialVersionUID = 1L; private final String appPackageName; private final String appTitle; private final String appVersionCode; private final Map attributes; private final String clientSdkVersion; private final String eventType; private final Map metrics; private final String sdkName; private final Session session; private final String timestamp; private Event(BuilderImpl builder) { this.appPackageName = builder.appPackageName; this.appTitle = builder.appTitle; this.appVersionCode = builder.appVersionCode; this.attributes = builder.attributes; this.clientSdkVersion = builder.clientSdkVersion; this.eventType = builder.eventType; this.metrics = builder.metrics; this.sdkName = builder.sdkName; this.session = builder.session; this.timestamp = builder.timestamp; } /** *

* The package name of the app that's recording the event. *

* * @return The package name of the app that's recording the event. */ public final String appPackageName() { return appPackageName; } /** *

* The title of the app that's recording the event. *

* * @return The title of the app that's recording the event. */ public final String appTitle() { return appTitle; } /** *

* The version number of the app that's recording the event. *

* * @return The version number of the app that's recording the event. */ public final String appVersionCode() { return appVersionCode; } /** * Returns true if the Attributes property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasAttributes() { return attributes != null && !(attributes instanceof SdkAutoConstructMap); } /** *

* One or more custom attributes that are associated with the event. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasAttributes()} to see if a value was sent in this field. *

* * @return One or more custom attributes that are associated with the event. */ public final Map attributes() { return attributes; } /** *

* The version of the SDK that's running on the client device. *

* * @return The version of the SDK that's running on the client device. */ public final String clientSdkVersion() { return clientSdkVersion; } /** *

* The name of the event. *

* * @return The name of the event. */ public final String eventType() { return eventType; } /** * Returns true if the Metrics property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasMetrics() { return metrics != null && !(metrics instanceof SdkAutoConstructMap); } /** *

* One or more custom metrics that are associated with the event. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasMetrics()} to see if a value was sent in this field. *

* * @return One or more custom metrics that are associated with the event. */ public final Map metrics() { return metrics; } /** *

* The name of the SDK that's being used to record the event. *

* * @return The name of the SDK that's being used to record the event. */ public final String sdkName() { return sdkName; } /** *

* Information about the session in which the event occurred. *

* * @return Information about the session in which the event occurred. */ public final Session session() { return session; } /** *

* The date and time, in ISO 8601 format, when the event occurred. *

* * @return The date and time, in ISO 8601 format, when the event occurred. */ public final String timestamp() { return timestamp; } @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(appPackageName()); hashCode = 31 * hashCode + Objects.hashCode(appTitle()); hashCode = 31 * hashCode + Objects.hashCode(appVersionCode()); hashCode = 31 * hashCode + Objects.hashCode(hasAttributes() ? attributes() : null); hashCode = 31 * hashCode + Objects.hashCode(clientSdkVersion()); hashCode = 31 * hashCode + Objects.hashCode(eventType()); hashCode = 31 * hashCode + Objects.hashCode(hasMetrics() ? metrics() : null); hashCode = 31 * hashCode + Objects.hashCode(sdkName()); hashCode = 31 * hashCode + Objects.hashCode(session()); hashCode = 31 * hashCode + Objects.hashCode(timestamp()); 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 Event)) { return false; } Event other = (Event) obj; return Objects.equals(appPackageName(), other.appPackageName()) && Objects.equals(appTitle(), other.appTitle()) && Objects.equals(appVersionCode(), other.appVersionCode()) && hasAttributes() == other.hasAttributes() && Objects.equals(attributes(), other.attributes()) && Objects.equals(clientSdkVersion(), other.clientSdkVersion()) && Objects.equals(eventType(), other.eventType()) && hasMetrics() == other.hasMetrics() && Objects.equals(metrics(), other.metrics()) && Objects.equals(sdkName(), other.sdkName()) && Objects.equals(session(), other.session()) && Objects.equals(timestamp(), other.timestamp()); } /** * 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("Event").add("AppPackageName", appPackageName()).add("AppTitle", appTitle()) .add("AppVersionCode", appVersionCode()).add("Attributes", hasAttributes() ? attributes() : null) .add("ClientSdkVersion", clientSdkVersion()).add("EventType", eventType()) .add("Metrics", hasMetrics() ? metrics() : null).add("SdkName", sdkName()).add("Session", session()) .add("Timestamp", timestamp()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "AppPackageName": return Optional.ofNullable(clazz.cast(appPackageName())); case "AppTitle": return Optional.ofNullable(clazz.cast(appTitle())); case "AppVersionCode": return Optional.ofNullable(clazz.cast(appVersionCode())); case "Attributes": return Optional.ofNullable(clazz.cast(attributes())); case "ClientSdkVersion": return Optional.ofNullable(clazz.cast(clientSdkVersion())); case "EventType": return Optional.ofNullable(clazz.cast(eventType())); case "Metrics": return Optional.ofNullable(clazz.cast(metrics())); case "SdkName": return Optional.ofNullable(clazz.cast(sdkName())); case "Session": return Optional.ofNullable(clazz.cast(session())); case "Timestamp": return Optional.ofNullable(clazz.cast(timestamp())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((Event) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The package name of the app that's recording the event. *

* * @param appPackageName * The package name of the app that's recording the event. * @return Returns a reference to this object so that method calls can be chained together. */ Builder appPackageName(String appPackageName); /** *

* The title of the app that's recording the event. *

* * @param appTitle * The title of the app that's recording the event. * @return Returns a reference to this object so that method calls can be chained together. */ Builder appTitle(String appTitle); /** *

* The version number of the app that's recording the event. *

* * @param appVersionCode * The version number of the app that's recording the event. * @return Returns a reference to this object so that method calls can be chained together. */ Builder appVersionCode(String appVersionCode); /** *

* One or more custom attributes that are associated with the event. *

* * @param attributes * One or more custom attributes that are associated with the event. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attributes(Map attributes); /** *

* The version of the SDK that's running on the client device. *

* * @param clientSdkVersion * The version of the SDK that's running on the client device. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientSdkVersion(String clientSdkVersion); /** *

* The name of the event. *

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

* One or more custom metrics that are associated with the event. *

* * @param metrics * One or more custom metrics that are associated with the event. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metrics(Map metrics); /** *

* The name of the SDK that's being used to record the event. *

* * @param sdkName * The name of the SDK that's being used to record the event. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sdkName(String sdkName); /** *

* Information about the session in which the event occurred. *

* * @param session * Information about the session in which the event occurred. * @return Returns a reference to this object so that method calls can be chained together. */ Builder session(Session session); /** *

* Information about the session in which the event occurred. *

* This is a convenience that creates an instance of the {@link Session.Builder} avoiding the need to create one * manually via {@link Session#builder()}. * * When the {@link Consumer} completes, {@link Session.Builder#build()} is called immediately and its result is * passed to {@link #session(Session)}. * * @param session * a consumer that will call methods on {@link Session.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #session(Session) */ default Builder session(Consumer session) { return session(Session.builder().applyMutation(session).build()); } /** *

* The date and time, in ISO 8601 format, when the event occurred. *

* * @param timestamp * The date and time, in ISO 8601 format, when the event occurred. * @return Returns a reference to this object so that method calls can be chained together. */ Builder timestamp(String timestamp); } static final class BuilderImpl implements Builder { private String appPackageName; private String appTitle; private String appVersionCode; private Map attributes = DefaultSdkAutoConstructMap.getInstance(); private String clientSdkVersion; private String eventType; private Map metrics = DefaultSdkAutoConstructMap.getInstance(); private String sdkName; private Session session; private String timestamp; private BuilderImpl() { } private BuilderImpl(Event model) { appPackageName(model.appPackageName); appTitle(model.appTitle); appVersionCode(model.appVersionCode); attributes(model.attributes); clientSdkVersion(model.clientSdkVersion); eventType(model.eventType); metrics(model.metrics); sdkName(model.sdkName); session(model.session); timestamp(model.timestamp); } public final String getAppPackageName() { return appPackageName; } @Override public final Builder appPackageName(String appPackageName) { this.appPackageName = appPackageName; return this; } public final void setAppPackageName(String appPackageName) { this.appPackageName = appPackageName; } public final String getAppTitle() { return appTitle; } @Override public final Builder appTitle(String appTitle) { this.appTitle = appTitle; return this; } public final void setAppTitle(String appTitle) { this.appTitle = appTitle; } public final String getAppVersionCode() { return appVersionCode; } @Override public final Builder appVersionCode(String appVersionCode) { this.appVersionCode = appVersionCode; return this; } public final void setAppVersionCode(String appVersionCode) { this.appVersionCode = appVersionCode; } public final Map getAttributes() { if (attributes instanceof SdkAutoConstructMap) { return null; } return attributes; } @Override public final Builder attributes(Map attributes) { this.attributes = MapOf__stringCopier.copy(attributes); return this; } public final void setAttributes(Map attributes) { this.attributes = MapOf__stringCopier.copy(attributes); } public final String getClientSdkVersion() { return clientSdkVersion; } @Override public final Builder clientSdkVersion(String clientSdkVersion) { this.clientSdkVersion = clientSdkVersion; return this; } public final void setClientSdkVersion(String clientSdkVersion) { this.clientSdkVersion = clientSdkVersion; } public final String getEventType() { return eventType; } @Override public final Builder eventType(String eventType) { this.eventType = eventType; return this; } public final void setEventType(String eventType) { this.eventType = eventType; } public final Map getMetrics() { if (metrics instanceof SdkAutoConstructMap) { return null; } return metrics; } @Override public final Builder metrics(Map metrics) { this.metrics = MapOf__doubleCopier.copy(metrics); return this; } public final void setMetrics(Map metrics) { this.metrics = MapOf__doubleCopier.copy(metrics); } public final String getSdkName() { return sdkName; } @Override public final Builder sdkName(String sdkName) { this.sdkName = sdkName; return this; } public final void setSdkName(String sdkName) { this.sdkName = sdkName; } public final Session.Builder getSession() { return session != null ? session.toBuilder() : null; } @Override public final Builder session(Session session) { this.session = session; return this; } public final void setSession(Session.BuilderImpl session) { this.session = session != null ? session.build() : null; } public final String getTimestamp() { return timestamp; } @Override public final Builder timestamp(String timestamp) { this.timestamp = timestamp; return this; } public final void setTimestamp(String timestamp) { this.timestamp = timestamp; } @Override public Event build() { return new Event(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy