Class EventBuilder<T>
- java.lang.Object
-
- org.odpi.openmetadata.connector.sas.event.model.EventBuilder<T>
-
- Type Parameters:
T- the type of data included within the event
public class EventBuilder<T> extends java.lang.ObjectBuilder used for constructing event instances.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Event<T>build()Builds a new event instance.static <T> EventBuilder<T>fromEvent(Event<T> event)Creates a builder for a newEventinstance.EventBuilder<T>header(java.lang.String key, java.lang.Object value)Adds a header to the event.EventBuilder<T>headers(EventHeaders headers)Adds a set of event headers.EventBuilder<T>idIfAbsent(java.lang.String id)Sets the id of the event, if not already present.EventBuilder<T>payloadType(java.lang.String payloadType)Sets the type of payload associated with the event.EventBuilder<T>timeStamp(java.util.Date timeStamp)Set the date value for which this event represents.EventBuilder<T>type(java.lang.String type)Sets the specific type of event.EventBuilder<T>user(java.lang.String user)Sets the name of the user associated with the event.static <T> EventBuilder<T>withPayload(T payload)Creates a new event builder with the specified data payload
-
-
-
Method Detail
-
header
public EventBuilder<T> header(java.lang.String key, java.lang.Object value)
Adds a header to the event.- Parameters:
key- the header's name, or keyvalue- the header's value- Returns:
- the builder
-
headers
public EventBuilder<T> headers(EventHeaders headers)
Adds a set of event headers.- Parameters:
headers- the event headers- Returns:
- the builder
-
idIfAbsent
public EventBuilder<T> idIfAbsent(java.lang.String id)
Sets the id of the event, if not already present.- Parameters:
id- the event's id- Returns:
- the builder
-
type
public EventBuilder<T> type(java.lang.String type)
Sets the specific type of event. During construction of the event, the event's type can be inferred from the payload assuming the payload is an instance ofTypedPayload, in which case it is not required to set the specific type. For all other cases though, the event type must be set.- Parameters:
type- the event type- Returns:
- the builder
-
payloadType
public EventBuilder<T> payloadType(java.lang.String payloadType)
Sets the type of payload associated with the event. The payloadType informs consumers the exact type of the payload object that can be expected, as well as allows a consumer to properly deserialize the event into the correct Java bean.During construction of the event, the payload type can be inferred from the payload assuming the payload is an instance of
TypedPayload, in which case it is not required to set the specific type.- Parameters:
payloadType- the payload type- Returns:
- the builder
-
user
public EventBuilder<T> user(java.lang.String user)
Sets the name of the user associated with the event.This value may differ depending on the context. For example, this may represent the actual user currently authenticated within the system, or it may represent a system wide user that is executing an operation on behalf of someone.
- Parameters:
user- the user id associated with the event- Returns:
- the builder
-
timeStamp
public EventBuilder<T> timeStamp(java.util.Date timeStamp)
Set the date value for which this event represents. Must be less than or equal to the publishedTimeStamp field. Used in situations where an event can be fired based on an action that occurred in the past.- Parameters:
timeStamp- the date of the event- Returns:
- the builder
-
withPayload
public static <T> EventBuilder<T> withPayload(T payload)
Creates a new event builder with the specified data payload- Type Parameters:
T- the payload type- Parameters:
payload- the event payload- Returns:
- event builder
-
fromEvent
public static <T> EventBuilder<T> fromEvent(Event<T> event)
Creates a builder for a newEventinstance. The contents of the new event will be pre-populated based on the contents of the original event.- Type Parameters:
T- the payload type- Parameters:
event- the original event- Returns:
- event builder
-
-