Class BaseCloudEventMetadata<T>

java.lang.Object
io.smallrye.reactive.messaging.ce.impl.BaseCloudEventMetadata<T>
Type Parameters:
T - the type of data
All Implemented Interfaces:
CloudEventMetadata<T>
Direct Known Subclasses:
DefaultIncomingCloudEventMetadata, DefaultOutgoingCloudEventMetadata

public class BaseCloudEventMetadata<T> extends Object implements CloudEventMetadata<T>
Default implementation of the CloudEventMetadata interface
  • Field Details

    • id

      protected final String id
    • specVersion

      protected final String specVersion
    • source

      protected final URI source
    • type

      protected final String type
    • dataContentType

      protected final String dataContentType
    • dataSchema

      protected final URI dataSchema
    • subject

      protected final String subject
    • timestamp

      protected final ZonedDateTime timestamp
    • extensions

      protected final Map<String,Object> extensions
    • data

      protected final T data
  • Constructor Details

  • Method Details

    • validate

      public void validate()
    • getId

      public String getId()
      Description copied from interface: CloudEventMetadata
      Identifies the event. Mandatory attribute.
      Specified by:
      getId in interface CloudEventMetadata<T>
      Returns:
      the id, cannot be null
    • getSource

      public URI getSource()
      Description copied from interface: CloudEventMetadata
      Identifies the context in which an event happened. Mandatory attribute.
      Specified by:
      getSource in interface CloudEventMetadata<T>
      Returns:
      the source, cannot be null
    • getSpecVersion

      public String getSpecVersion()
      Description copied from interface: CloudEventMetadata
      The version of the CloudEvents specification which the event uses. Mandatory attribute.
      Specified by:
      getSpecVersion in interface CloudEventMetadata<T>
      Returns:
      the specification version
    • getType

      public String getType()
      Description copied from interface: CloudEventMetadata
      This attribute contains a value describing the type of event related to the originating occurrence. Mandatory attribute.
      Specified by:
      getType in interface CloudEventMetadata<T>
      Returns:
      the type
    • getDataContentType

      public Optional<String> getDataContentType()
      Description copied from interface: CloudEventMetadata
      Content type of data value.
      Specified by:
      getDataContentType in interface CloudEventMetadata<T>
      Returns:
      the content type if any, empty if none.
    • getDataSchema

      public Optional<URI> getDataSchema()
      Description copied from interface: CloudEventMetadata
      Identifies the schema that data adheres to.
      Specified by:
      getDataSchema in interface CloudEventMetadata<T>
      Returns:
      the schema URI if any, empty if none.
    • getSubject

      public Optional<String> getSubject()
      Description copied from interface: CloudEventMetadata
      This describes the subject of the event in the context of the event producer (identified by source).
      Specified by:
      getSubject in interface CloudEventMetadata<T>
      Returns:
      the subject if any, empty if none
    • getTimeStamp

      public Optional<ZonedDateTime> getTimeStamp()
      Description copied from interface: CloudEventMetadata
      Timestamp of when the occurrence happened.
      Specified by:
      getTimeStamp in interface CloudEventMetadata<T>
      Returns:
      the timestamp if any, empty if none
    • getExtension

      public <A> Optional<A> getExtension(String name)
      Description copied from interface: CloudEventMetadata
      A CloudEvent may include any number of additional context attributes with distinct names, known as "extension attributes". This method allows retrieving these attributes.
      Specified by:
      getExtension in interface CloudEventMetadata<T>
      Parameters:
      name - the name of the attribute, must not be null
      Returns:
      the value of the attribute, empty if not present.
    • getExtensions

      public Map<String,Object> getExtensions()
      Description copied from interface: CloudEventMetadata
      A CloudEvent may include any number of additional context attributes with distinct names, known as "extension attributes". This method allows retrieving these attributes.
      Specified by:
      getExtensions in interface CloudEventMetadata<T>
      Returns:
      the map of extension attributes, potentially empty.
    • getData

      public T getData()
      Description copied from interface: CloudEventMetadata
      The event payload. It is the owner message payload.
      Specified by:
      getData in interface CloudEventMetadata<T>
      Returns:
      the payload, can be null