Class CloudEventBuilder

All Implemented Interfaces:
CloudEventBuilder, io.cloudevents.rw.CloudEventContextWriter, io.cloudevents.rw.CloudEventWriter<io.cloudevents.CloudEvent>

public final class CloudEventBuilder extends BaseCloudEventBuilder<CloudEventBuilder,CloudEventV03>
CloudEvent V0.3 builder.
Author:
fabiojose, slinkydeveloper
  • Constructor Details

    • CloudEventBuilder

      public CloudEventBuilder()
    • CloudEventBuilder

      public CloudEventBuilder(io.cloudevents.CloudEvent event)
    • CloudEventBuilder

      public CloudEventBuilder(io.cloudevents.CloudEventContext context)
  • Method Details

    • setAttributes

      protected void setAttributes(io.cloudevents.CloudEventContext event)
      Specified by:
      setAttributes in class BaseCloudEventBuilder<CloudEventBuilder,CloudEventV03>
    • withId

      public CloudEventBuilder withId(String id)
      Description copied from interface: CloudEventBuilder
      Set the id of the event
      Parameters:
      id - id of the event
      Returns:
      self
    • withSource

      public CloudEventBuilder withSource(URI source)
      Description copied from interface: CloudEventBuilder
      Set the source of the event
      Parameters:
      source - source of the event
      Returns:
      self
    • withType

      public CloudEventBuilder withType(String type)
      Description copied from interface: CloudEventBuilder
      Set the type of the event
      Parameters:
      type - type of the event
      Returns:
      self
    • withTime

      public CloudEventBuilder withTime(OffsetDateTime time)
      Description copied from interface: CloudEventBuilder
      Set the time of the event
      Parameters:
      time - time of the event
      Returns:
      self
    • withSubject

      public CloudEventBuilder withSubject(String subject)
      Description copied from interface: CloudEventBuilder
      Set the subject of the event
      Parameters:
      subject - subject of the event
      Returns:
      self
    • withDataContentType

      public CloudEventBuilder withDataContentType(String dataContentType)
      Description copied from interface: CloudEventBuilder
      Set the datacontenttype of the event
      Parameters:
      dataContentType - datacontenttype of the event
      Returns:
      self
    • withSchemaUrl

      public CloudEventBuilder withSchemaUrl(URI schemaUrl)
    • withDataSchema

      public CloudEventBuilder withDataSchema(URI dataSchema)
      Description copied from interface: CloudEventBuilder
      Set the dataschema of the event. For CloudEvent v0.3, this will configure the schemaurl attribute.
      Parameters:
      dataSchema - dataschema of the event
      Returns:
      self
    • build

      public CloudEventV03 build()
      Description copied from interface: CloudEventBuilder
      Build the event
      Returns:
      the built event
    • newBuilder

      public CloudEventBuilder newBuilder()
      Description copied from interface: CloudEventBuilder
      Copy this builder, creating a new instance with same values.
      Returns:
      A new builder with same values of this instance
    • withContextAttribute

      public io.cloudevents.rw.CloudEventContextWriter withContextAttribute(String name, String value) throws io.cloudevents.rw.CloudEventRWException
      Throws:
      io.cloudevents.rw.CloudEventRWException
    • withContextAttribute

      public io.cloudevents.rw.CloudEventContextWriter withContextAttribute(String name, URI value) throws io.cloudevents.rw.CloudEventRWException
      Throws:
      io.cloudevents.rw.CloudEventRWException
    • withContextAttribute

      public io.cloudevents.rw.CloudEventContextWriter withContextAttribute(String name, OffsetDateTime value) throws io.cloudevents.rw.CloudEventRWException
      Throws:
      io.cloudevents.rw.CloudEventRWException
    • withContextAttribute

      public io.cloudevents.rw.CloudEventContextWriter withContextAttribute(String name, Number value) throws io.cloudevents.rw.CloudEventRWException
      Throws:
      io.cloudevents.rw.CloudEventRWException
    • withContextAttribute

      public io.cloudevents.rw.CloudEventContextWriter withContextAttribute(String name, Integer value) throws io.cloudevents.rw.CloudEventRWException
      Throws:
      io.cloudevents.rw.CloudEventRWException
    • withContextAttribute

      public io.cloudevents.rw.CloudEventContextWriter withContextAttribute(String name, Boolean value) throws io.cloudevents.rw.CloudEventRWException
      Throws:
      io.cloudevents.rw.CloudEventRWException
    • withContextAttribute

      public io.cloudevents.rw.CloudEventContextWriter withContextAttribute(String name, byte[] value) throws io.cloudevents.rw.CloudEventRWException
      Throws:
      io.cloudevents.rw.CloudEventRWException