public static class

CustomEvent.Builder

extends Object
java.lang.Object
   ↳ com.urbanairship.analytics.CustomEvent.Builder

Class Overview

Builder class for CustomEvent Objects.

Summary

Public Constructors
Builder(String eventName)
Creates a new custom event builder

The event name must be between 1 and 255 characters or the event will be invalid.

Public Methods
CustomEvent.Builder addProperty(String name, JsonSerializable value)
Adds a custom property to the event.
CustomEvent.Builder addProperty(String name, boolean value)
Adds a custom property to the event.
CustomEvent.Builder addProperty(String name, int value)
Adds a custom property to the event.
CustomEvent.Builder addProperty(String name, double value)
Adds a custom property to the event.
CustomEvent.Builder addProperty(String name, String value)
Adds a custom property to the event.
CustomEvent.Builder addProperty(String name, long value)
Adds a custom property to the event.
CustomEvent build()
Builds the custom event.
CustomEvent.Builder setEventValue(double value)
Sets the event value.
CustomEvent.Builder setEventValue(int value)
Sets the event value.
CustomEvent.Builder setEventValue(String value)
Sets the event value from a String.
CustomEvent.Builder setEventValue(BigDecimal value)
Sets the event value.
CustomEvent.Builder setInteraction(String interactionType, String interactionId)
Sets the interaction type and ID for the event.
CustomEvent.Builder setMessageCenterInteraction(String richPushMessageId)
Sets the interaction type and ID from a Message Center message.
CustomEvent.Builder setProperties(JsonMap properties)
Sets a JsonMap representing the event properties.
CustomEvent.Builder setTransactionId(String transactionId)
Sets the transaction ID.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Builder (String eventName)

Creates a new custom event builder

The event name must be between 1 and 255 characters or the event will be invalid.

Parameters
eventName The name of the event.
Throws
IllegalArgumentException if the event name is null, empty, or exceeds 255 characters.

Public Methods

public CustomEvent.Builder addProperty (String name, JsonSerializable value)

Adds a custom property to the event.

If the total added properties exceed MAX_TOTAL_PROPERTIES_SIZE in size it will cause the event to be invalid.

Parameters
name The property name.
value A property value.
Returns
  • The custom event builder.

public CustomEvent.Builder addProperty (String name, boolean value)

Adds a custom property to the event.

If the total number of properties exceed MAX_TOTAL_PROPERTIES_SIZE it will cause the event to be invalid.

Parameters
name The property name.
value The property value.
Returns
  • The custom event builder.

public CustomEvent.Builder addProperty (String name, int value)

Adds a custom property to the event.

If the total added properties exceed MAX_TOTAL_PROPERTIES_SIZE in size it will cause the event to be invalid.

Parameters
name The property name.
value The property value.
Returns
  • The custom event builder.

public CustomEvent.Builder addProperty (String name, double value)

Adds a custom property to the event.

If the total number of properties exceed MAX_TOTAL_PROPERTIES_SIZE it will cause the event to be invalid.

Parameters
name The property name.
value The property value.
Returns
  • The custom event builder.
Throws
NumberFormatException if the value is infinite or not a number

public CustomEvent.Builder addProperty (String name, String value)

Adds a custom property to the event.

If the total added properties exceed MAX_TOTAL_PROPERTIES_SIZE in size it will cause the event to be invalid.

Parameters
name The property name.
value The property value.
Returns
  • The custom event builder.

public CustomEvent.Builder addProperty (String name, long value)

Adds a custom property to the event.

If the total added properties exceed MAX_TOTAL_PROPERTIES_SIZE in size it will cause the event to be invalid.

Parameters
name The property name.
value The property value.
Returns
  • The custom event builder.

public CustomEvent build ()

Builds the custom event.

Returns
  • The built custom event.

public CustomEvent.Builder setEventValue (double value)

Sets the event value.

The event's value will be accurate 6 digits after the decimal. The number must fall in the range [-2^31, 2^31-1]. Any value outside that range will cause the event to be invalid.

Parameters
value The event's value as a double
Returns
  • The custom event builder.
Throws
NumberFormatException if the value is infinity or not a number.

public CustomEvent.Builder setEventValue (int value)

Sets the event value.

Parameters
value The event's value as an int.
Returns
  • The custom event builder.

public CustomEvent.Builder setEventValue (String value)

Sets the event value from a String.

The event's value will be accurate 6 digits after the decimal. The number must fall in the range [-2^31, 2^31-1]. Any value outside that range will cause the event to be invalid.

Parameters
value The event's value as a String.
Returns
  • The custom event builder.
Throws
NumberFormatException if the event value does not contain a valid string representation of a big decimal.

public CustomEvent.Builder setEventValue (BigDecimal value)

Sets the event value.

The event's value will be accurate 6 digits after the decimal. The number must fall in the range [-2^31, 2^31-1]. Any value outside that range will cause the event to be invalid.

Parameters
value The event's value as a BigDecimal.
Returns
  • The custom event builder.

public CustomEvent.Builder setInteraction (String interactionType, String interactionId)

Sets the interaction type and ID for the event.

If any non-property field exceeds MAX_CHARACTER_LENGTH characters it will cause the event to be invalid.

Parameters
interactionType The event's interaction type.
interactionId The event's interaction ID.
Returns
  • The custom event builder.

public CustomEvent.Builder setMessageCenterInteraction (String richPushMessageId)

Sets the interaction type and ID from a Message Center message.

Parameters
richPushMessageId The rich push message ID that created the custom event.
Returns
  • The custom event builder.

public CustomEvent.Builder setProperties (JsonMap properties)

Sets a JsonMap representing the event properties.

If the total added properties exceed MAX_TOTAL_PROPERTIES_SIZE in size it will cause the event to be invalid.

Parameters
properties A JsonMap of the event's properties.
Returns
  • The custom event builder.

public CustomEvent.Builder setTransactionId (String transactionId)

Sets the transaction ID.

If the transaction ID exceeds MAX_CHARACTER_LENGTH characters it will cause the event to be invalid.

Parameters
transactionId The event's transaction ID.
Returns
  • The custom event builder.