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, 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, Collection<String> 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 create()
This method is deprecated. Use `build` instead.
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(RichPushMessage message)
Sets the interaction type and ID from a RichPushMessage.
CustomEvent.Builder setInteraction(String interactionType, String interactionId)
Sets the interaction type and ID for the event.
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, boolean value)

Adds a custom property to the event.

If the max number of properties exceeds MAX_PROPERTIES, or if the name of the property exceeds MAX_CHARACTER_LENGTH 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 max number of properties exceeds MAX_PROPERTIES, or if the name of the property exceeds MAX_CHARACTER_LENGTH 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, Collection<String> value)

Adds a custom property to the event.

If the max number of properties exceeds MAX_PROPERTIES, if the name of the property, or any of the Strings within its value exceeds MAX_CHARACTER_LENGTH, or if the value contains more than MAX_PROPERTY_COLLECTION_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 max number of properties exceeds MAX_PROPERTIES, or if the name of the property exceeds MAX_CHARACTER_LENGTH 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 max number of properties exceeds MAX_PROPERTIES, or if the name or value of the property exceeds MAX_CHARACTER_LENGTH 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 max number of properties exceeds MAX_PROPERTIES, or if the name of the property exceeds MAX_CHARACTER_LENGTH 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 create ()

This method is deprecated.
Use `build` instead.

Creates the custom event.

Returns
  • The created 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 (RichPushMessage message)

Sets the interaction type and ID from a RichPushMessage.

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

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

Sets the interaction type and ID for the event.

If any field exceeds 255 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 setTransactionId (String transactionId)

Sets the transaction ID.

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

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