Class BaseCloudEventBuilder<SELF extends BaseCloudEventBuilder<SELF,T>,T extends io.cloudevents.CloudEvent>

java.lang.Object
io.cloudevents.core.impl.BaseCloudEventBuilder<SELF,T>
All Implemented Interfaces:
CloudEventBuilder, io.cloudevents.rw.CloudEventContextWriter, io.cloudevents.rw.CloudEventWriter<io.cloudevents.CloudEvent>
Direct Known Subclasses:
CloudEventBuilder, CloudEventBuilder

public abstract class BaseCloudEventBuilder<SELF extends BaseCloudEventBuilder<SELF,T>,T extends io.cloudevents.CloudEvent> extends Object implements CloudEventBuilder
  • Field Details

    • data

      protected io.cloudevents.CloudEventData data
    • extensions

      protected Map<String,Object> extensions
  • Constructor Details

    • BaseCloudEventBuilder

      public BaseCloudEventBuilder()
    • BaseCloudEventBuilder

      public BaseCloudEventBuilder(io.cloudevents.CloudEventContext context)
    • BaseCloudEventBuilder

      public BaseCloudEventBuilder(io.cloudevents.CloudEvent event)
  • Method Details

    • setAttributes

      protected abstract void setAttributes(io.cloudevents.CloudEventContext event)
    • withData

      public SELF withData(byte[] data)
      Description copied from interface: CloudEventBuilder
      Set the data of the event
      Specified by:
      withData in interface CloudEventBuilder
      Parameters:
      data - data of the event
      Returns:
      self
    • withData

      public SELF withData(String dataContentType, byte[] data)
      Description copied from interface: CloudEventBuilder
      Set the datacontenttype and data of the event
      Specified by:
      withData in interface CloudEventBuilder
      Parameters:
      dataContentType - datacontenttype of the event
      data - data of the event
      Returns:
      self
    • withData

      public SELF withData(String dataContentType, URI dataSchema, byte[] data)
      Description copied from interface: CloudEventBuilder
      Set the datacontenttype, dataschema and data of the event
      Specified by:
      withData in interface CloudEventBuilder
      Parameters:
      dataContentType - datacontenttype of the event
      dataSchema - dataschema of the event
      data - data of the event
      Returns:
      self
    • withData

      public SELF withData(io.cloudevents.CloudEventData data)
      Description copied from interface: CloudEventBuilder
      Set the data of the event
      Specified by:
      withData in interface CloudEventBuilder
      Parameters:
      data - data of the event
      Returns:
      self
    • withData

      public SELF withData(String dataContentType, io.cloudevents.CloudEventData data)
      Description copied from interface: CloudEventBuilder
      Set the datacontenttype and data of the event
      Specified by:
      withData in interface CloudEventBuilder
      Parameters:
      dataContentType - datacontenttype of the event
      data - data of the event
      Returns:
      self
    • withData

      public SELF withData(String dataContentType, URI dataSchema, io.cloudevents.CloudEventData data)
      Description copied from interface: CloudEventBuilder
      Set the datacontenttype, dataschema and data of the event
      Specified by:
      withData in interface CloudEventBuilder
      Parameters:
      dataContentType - datacontenttype of the event
      dataSchema - dataschema of the event
      data - data of the event
      Returns:
      self
    • withoutData

      public CloudEventBuilder withoutData()
      Description copied from interface: CloudEventBuilder
      Remove the datacontenttype, dataschema and data from the event
      Specified by:
      withoutData in interface CloudEventBuilder
      Returns:
      self
    • withoutDataSchema

      public CloudEventBuilder withoutDataSchema()
      Description copied from interface: CloudEventBuilder
      Remove the dataschema from the event
      Specified by:
      withoutDataSchema in interface CloudEventBuilder
      Returns:
      self
    • withoutDataContentType

      public CloudEventBuilder withoutDataContentType()
      Description copied from interface: CloudEventBuilder
      Remove the datacontenttype from the event
      Specified by:
      withoutDataContentType in interface CloudEventBuilder
      Returns:
      self
    • withExtension

      public SELF withExtension(@Nonnull String key, @Nonnull String value)
      Description copied from interface: CloudEventBuilder
      Set an extension with provided key and string value
      Specified by:
      withExtension in interface CloudEventBuilder
      Parameters:
      key - key of the extension attribute
      value - value of the extension attribute
      Returns:
      self
    • withExtension

      public SELF withExtension(@Nonnull String key, @Nonnull Number value)
      Description copied from interface: CloudEventBuilder
      Set an extension with provided key and numeric value
      Specified by:
      withExtension in interface CloudEventBuilder
      Parameters:
      key - key of the extension attribute
      value - value of the extension attribute
      Returns:
      self
    • withExtension

      public SELF withExtension(@Nonnull String key, @Nonnull Integer value)
    • withExtension

      public SELF withExtension(@Nonnull String key, @Nonnull Boolean value)
      Description copied from interface: CloudEventBuilder
      Set an extension with provided key and boolean value
      Specified by:
      withExtension in interface CloudEventBuilder
      Parameters:
      key - key of the extension attribute
      value - value of the extension attribute
      Returns:
      self
    • withExtension

      public SELF withExtension(@Nonnull String key, @Nonnull URI value)
      Description copied from interface: CloudEventBuilder
      Set an extension with provided key and uri value
      Specified by:
      withExtension in interface CloudEventBuilder
      Parameters:
      key - key of the extension attribute
      value - value of the extension attribute
      Returns:
      self
    • withExtension

      public SELF withExtension(@Nonnull String key, @Nonnull OffsetDateTime value)
      Description copied from interface: CloudEventBuilder
      Set an extension with provided key and boolean value
      Specified by:
      withExtension in interface CloudEventBuilder
      Parameters:
      key - key of the extension attribute
      value - value of the extension attribute
      Returns:
      self
    • withExtension

      public CloudEventBuilder withExtension(@Nonnull String key, @Nonnull byte[] value)
      Description copied from interface: CloudEventBuilder
      Set an extension with provided key and binary value
      Specified by:
      withExtension in interface CloudEventBuilder
      Parameters:
      key - key of the extension attribute
      value - value of the extension attribute
      Returns:
      self
    • withoutExtension

      public SELF withoutExtension(@Nonnull String key)
      Description copied from interface: CloudEventBuilder
      Remove from the the builder the provided extension key, if any
      Specified by:
      withoutExtension in interface CloudEventBuilder
      Parameters:
      key - key of the extension attribute
      Returns:
      self
    • withoutExtension

      public SELF withoutExtension(@Nonnull io.cloudevents.CloudEventExtension extension)
      Description copied from interface: CloudEventBuilder
      Remove from the the builder the provided extension, if any
      Specified by:
      withoutExtension in interface CloudEventBuilder
      Parameters:
      extension - materialized extension to remove from the builder
      Returns:
      self
    • withExtension

      public SELF withExtension(@Nonnull io.cloudevents.CloudEventExtension extension)
      Description copied from interface: CloudEventBuilder
      Add to the builder all the extension key/values of the provided extension
      Specified by:
      withExtension in interface CloudEventBuilder
      Parameters:
      extension - materialized extension to set in the builder
      Returns:
      self
    • end

      public io.cloudevents.CloudEvent end(io.cloudevents.CloudEventData value) throws io.cloudevents.rw.CloudEventRWException
      Specified by:
      end in interface io.cloudevents.rw.CloudEventWriter<SELF extends BaseCloudEventBuilder<SELF,T>>
      Throws:
      io.cloudevents.rw.CloudEventRWException
    • end

      public io.cloudevents.CloudEvent end()
      Specified by:
      end in interface io.cloudevents.rw.CloudEventWriter<SELF extends BaseCloudEventBuilder<SELF,T>>
    • createMissingAttributeException

      protected static IllegalStateException createMissingAttributeException(String attributeName)
    • createEmptyAttributeException

      protected static IllegalStateException createEmptyAttributeException(String attributeName)
    • requireValidAttributeWrite

      protected void requireValidAttributeWrite(String name)