# CloudEvent (dapr-sdk-parent 1.10.0 API)

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
`static String` `CONTENT_TYPE` Mime type used for CloudEvent.
`protected static com.fasterxml.jackson.databind.ObjectMapper` `OBJECT_MAPPER` Shared Json serializer/deserializer as per Jackson's documentation.

### Constructor Summary

Constructors
`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

All Methods Static Methods Instance Methods Concrete Methods
`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` `getSource()` Gets the event's source.
`String` `getSpecversion()` Gets the version of the specification.
`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` `setSource​(String source)` Sets the event's source.
`void` `setSpecversion​(String specversion)` Sets the version of the specification.
`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 Detail

#### 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 Detail

#### 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 Detail

#### 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.

#### equals

    public boolean equals​(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`