Package io.dapr.client.domain

# Class CloudEvent<T>

java.lang.Object
io.dapr.client.domain.CloudEvent<T>

Type Parameters:
  `T` - The type of the payload.

public class CloudEvent<T> extends Object
A cloud event in Dapr.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `CONTENT_TYPE`
  Mime type used for CloudEvent.
  `protected static final com.fasterxml.jackson.databind.ObjectMapper`
  `OBJECT_MAPPER`
  Shared Json serializer/deserializer as per Jackson's documentation.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CloudEvent()`
  Instantiates a CloudEvent.
  `CloudEvent(String id, String source, String type, String specversion, byte[] binaryData)`
  Instantiates a CloudEvent.
  `CloudEvent(String id, String source, String type, String specversion, String datacontenttype, T data)`
  Instantiates a CloudEvent.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static CloudEvent<?>`
  `deserialize(byte[] payload)`
  Deserialize a message topic from Dapr.
  `boolean`
  `equals(Object o)`
  `byte[]`
  `getBinaryData()`
  Gets the cloud event's binary data.
  `T`
  `getData()`
  Gets the cloud event data.
  `String`
  `getDatacontenttype()`
  Gets the type of the data's content.
  `String`
  `getId()`
  Gets the identifier of the message being processed.
  `String`
  `getPubsubName()`
  Gets the pubsub component name.
  `String`
  `getSource()`
  Gets the event's source.
  `String`
  `getSpecversion()`
  Gets the version of the specification.
  `OffsetDateTime`
  `getTime()`
  Gets the time.
  `String`
  `getTopic()`
  Gets the topic name.
  `String`
  `getTraceId()`
  Deprecated.
  `String`
  `getTraceParent()`
  Gets the trace parent.
  `String`
  `getTraceState()`
  Gets the trace state.
  `String`
  `getType()`
  Gets the envelope type.
  `int`
  `hashCode()`
  `void`
  `setBinaryData(byte[] binaryData)`
  Sets the cloud event's binary data.
  `void`
  `setData(T data)`
  Sets the cloud event data.
  `void`
  `setDatacontenttype(String datacontenttype)`
  Sets the type of the data's content.
  `void`
  `setId(String id)`
  Sets the identifier of the message being processed.
  `void`
  `setPubsubName(String pubsubName)`
  Sets the pubsub component name.
  `void`
  `setSource(String source)`
  Sets the event's source.
  `void`
  `setSpecversion(String specversion)`
  Sets the version of the specification.
  `void`
  `setTime(OffsetDateTime time)`
  Sets the time.
  `void`
  `setTopic(String topic)`
  Sets the topic name.
  `void`
  `setTraceId(String traceId)`
  Deprecated.
  `void`
  `setTraceParent(String traceParent)`
  Sets the trace parent.
  `void`
  `setTraceState(String traceState)`
  Sets the trace state.
  `void`
  `setType(String type)`
  Sets the envelope type.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### CONTENT_TYPE

    public static final String CONTENT_TYPE
    Mime type used for CloudEvent.
    See Also:
      - Constant Field Values

  - ### OBJECT_MAPPER

    protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
    Shared Json serializer/deserializer as per Jackson's documentation.

- ## Constructor Details

  - ### CloudEvent

    public CloudEvent()
    Instantiates a CloudEvent.

  - ### CloudEvent

    public CloudEvent(String id, String source, String type, String specversion, String datacontenttype, T data)
    Instantiates a CloudEvent.
    Parameters:
      `id` - Identifier of the message being processed.
      `source` - Source for this event.
      `type` - Type of event.
      `specversion` - Version of the event spec.
      `datacontenttype` - Type of the payload.
      `data` - Payload.

  - ### CloudEvent

    public CloudEvent(String id, String source, String type, String specversion, byte[] binaryData)
    Instantiates a CloudEvent.
    Parameters:
      `id` - Identifier of the message being processed.
      `source` - Source for this event.
      `type` - Type of event.
      `specversion` - Version of the event spec.
      `binaryData` - Payload.

- ## Method Details

  - ### deserialize

    public static CloudEvent<?> deserialize(byte[] payload) throws IOException
    Deserialize a message topic from Dapr.
    Parameters:
      `payload` - Payload sent from Dapr.
    Returns:
      Message (can be null if input is null)
    Throws:
      `IOException` - If cannot parse.

  - ### getId

    public String getId()
    Gets the identifier of the message being processed.
    Returns:
      Identifier of the message being processed.

  - ### setId

    public void setId(String id)
    Sets the identifier of the message being processed.
    Parameters:
      `id` - Identifier of the message being processed.

  - ### getSource

    public String getSource()
    Gets the event's source.
    Returns:
      Event's source.

  - ### setSource

    public void setSource(String source)
    Sets the event's source.
    Parameters:
      `source` - Event's source.

  - ### getType

    public String getType()
    Gets the envelope type.
    Returns:
      Envelope type.

  - ### setType

    public void setType(String type)
    Sets the envelope type.
    Parameters:
      `type` - Envelope type.

  - ### getSpecversion

    public String getSpecversion()
    Gets the version of the specification.
    Returns:
      Version of the specification.

  - ### setSpecversion

    public void setSpecversion(String specversion)
    Sets the version of the specification.
    Parameters:
      `specversion` - Version of the specification.

  - ### getDatacontenttype

    public String getDatacontenttype()
    Gets the type of the data's content.
    Returns:
      Type of the data's content.

  - ### setDatacontenttype

    public void setDatacontenttype(String datacontenttype)
    Sets the type of the data's content.
    Parameters:
      `datacontenttype` - Type of the data's content.

  - ### getData

    public T getData()
    Gets the cloud event data.
    Returns:
      Cloud event's data. As per specs, data can be a JSON object or string.

  - ### setData

    public void setData(T data)
    Sets the cloud event data. As per specs, data can be a JSON object or string.
    Parameters:
      `data` - Cloud event's data. As per specs, data can be a JSON object or string.

  - ### getBinaryData

    public byte[] getBinaryData()
    Gets the cloud event's binary data.
    Returns:
      Cloud event's binary data.

  - ### setBinaryData

    public void setBinaryData(byte[] binaryData)
    Sets the cloud event's binary data.
    Parameters:
      `binaryData` - Cloud event's binary data.

  - ### getPubsubName

    public String getPubsubName()
    Gets the pubsub component name.
    Returns:
      the pubsub component name.

  - ### setPubsubName

    public void setPubsubName(String pubsubName)
    Sets the pubsub component name.
    Parameters:
      `pubsubName` - the pubsub component name.

  - ### getTopic

    public String getTopic()
    Gets the topic name.
    Returns:
      the topic name.

  - ### setTopic

    public void setTopic(String topic)
    Sets the topic name.
    Parameters:
      `topic` - the topic name.

  - ### getTime

    public OffsetDateTime getTime()
    Gets the time.
    Returns:
      the time.

  - ### setTime

    public void setTime(OffsetDateTime time)
    Sets the time.
    Parameters:
      `time` - the time.

  - ### getTraceId

    @Deprecated public String getTraceId()
    Deprecated.
    Gets the trace id which is the legacy name for trace parent.
    Returns:
      the trace id.

  - ### setTraceId

    @Deprecated public void setTraceId(String traceId)
    Deprecated.
    Sets the trace id which is the legacy name for trace parent.
    Parameters:
      `traceId` - the trace id.

  - ### getTraceParent

    public String getTraceParent()
    Gets the trace parent.
    Returns:
      the trace parent.

  - ### setTraceParent

    public void setTraceParent(String traceParent)
    Sets the trace parent.
    Parameters:
      `traceParent` - the trace parent.

  - ### getTraceState

    public String getTraceState()
    Gets the trace state.
    Returns:
      the trace state.

  - ### setTraceState

    public void setTraceState(String traceState)
    Sets the trace state.
    Parameters:
      `traceState` - the trace state.

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`