Class CloudEventsPayloadBuilder

java.lang.Object
com.commercetools.api.models.subscription.CloudEventsPayloadBuilder
All Implemented Interfaces:
Builder<CloudEventsPayload>

public class CloudEventsPayloadBuilder extends Object implements Builder<CloudEventsPayload>
CloudEventsPayloadBuilder
Example to create an instance using the builder pattern

     CloudEventsPayload cloudEventsPayload = CloudEventsPayload.builder()
             .specversion("{specversion}")
             .id("{id}")
             .type("{type}")
             .source("{source}")
             .subject("{subject}")
             .time(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .data(dataBuilder -> dataBuilder)
             .build()
 
  • Constructor Details

    • CloudEventsPayloadBuilder

      public CloudEventsPayloadBuilder()
  • Method Details

    • specversion

      public CloudEventsPayloadBuilder specversion(String specversion)

      The version of the CloudEvents specification which the event uses.

      Parameters:
      specversion - value to be set
      Returns:
      Builder
    • id

      Unique identifier of the event.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • type

      public CloudEventsPayloadBuilder type(String type)

      The type is namespaced with com.commercetools, followed by the ReferenceTypeId, the type of Subscription (either message or change), and the message or change type. For example, com.commercetools.product.message.ProductPublished or com.commercetools.order.change.ResourceCreated.

      Parameters:
      type - value to be set
      Returns:
      Builder
    • source

      public CloudEventsPayloadBuilder source(String source)

      The default REST URI of the ReferenceTypeId that triggered this event, including the project key.

      Parameters:
      source - value to be set
      Returns:
      Builder
    • subject

      public CloudEventsPayloadBuilder subject(String subject)

      Unique identifier of the resource that triggered the event.

      Parameters:
      subject - value to be set
      Returns:
      Builder
    • time

      Corresponds to the lastModifiedAt of the resource at the time the event was triggered.

      Parameters:
      time - value to be set
      Returns:
      Builder
    • sequence

      public CloudEventsPayloadBuilder sequence(@Nullable String sequence)

      Corresponds to the sequenceNumber of a MessageSubscription. Can be used to process messages in the correct order.

      Parameters:
      sequence - value to be set
      Returns:
      Builder
    • sequencetype

      public CloudEventsPayloadBuilder sequencetype(@Nullable String sequencetype)

      "Integer"

      Parameters:
      sequencetype - value to be set
      Returns:
      Builder
    • dataref

      public CloudEventsPayloadBuilder dataref(@Nullable String dataref)

      The URI from which the message can be retrieved if messages are enabled. Only set for MessageSubscriptions.

      Parameters:
      dataref - value to be set
      Returns:
      Builder
    • data

      MessageDeliveryPayload, ResourceCreatedDeliveryPayload, ResourceUpdatedDeliveryPayload, or ResourceDeletedDeliveryPayload.

      Parameters:
      data - value to be set
      Returns:
      Builder
    • data

      MessageDeliveryPayload, ResourceCreatedDeliveryPayload, ResourceUpdatedDeliveryPayload, or ResourceDeletedDeliveryPayload.

      Parameters:
      builder - function to build the data value
      Returns:
      Builder
    • getSpecversion

      public String getSpecversion()

      The version of the CloudEvents specification which the event uses.

      Returns:
      specversion
    • getId

      public String getId()

      Unique identifier of the event.

      Returns:
      id
    • getType

      public String getType()

      The type is namespaced with com.commercetools, followed by the ReferenceTypeId, the type of Subscription (either message or change), and the message or change type. For example, com.commercetools.product.message.ProductPublished or com.commercetools.order.change.ResourceCreated.

      Returns:
      type
    • getSource

      public String getSource()

      The default REST URI of the ReferenceTypeId that triggered this event, including the project key.

      Returns:
      source
    • getSubject

      public String getSubject()

      Unique identifier of the resource that triggered the event.

      Returns:
      subject
    • getTime

      public ZonedDateTime getTime()

      Corresponds to the lastModifiedAt of the resource at the time the event was triggered.

      Returns:
      time
    • getSequence

      @Nullable public String getSequence()

      Corresponds to the sequenceNumber of a MessageSubscription. Can be used to process messages in the correct order.

      Returns:
      sequence
    • getSequencetype

      @Nullable public String getSequencetype()

      "Integer"

      Returns:
      sequencetype
    • getDataref

      @Nullable public String getDataref()

      The URI from which the message can be retrieved if messages are enabled. Only set for MessageSubscriptions.

      Returns:
      dataref
    • getData

      public DeliveryPayload getData()

      MessageDeliveryPayload, ResourceCreatedDeliveryPayload, ResourceUpdatedDeliveryPayload, or ResourceDeletedDeliveryPayload.

      Returns:
      data
    • build

      public CloudEventsPayload build()
      builds CloudEventsPayload with checking for non-null required values
      Specified by:
      build in interface Builder<CloudEventsPayload>
      Returns:
      CloudEventsPayload
    • buildUnchecked

      public CloudEventsPayload buildUnchecked()
      builds CloudEventsPayload without checking for non-null required values
      Returns:
      CloudEventsPayload
    • of

      public static CloudEventsPayloadBuilder of()
      factory method for an instance of CloudEventsPayloadBuilder
      Returns:
      builder
    • of

      public static CloudEventsPayloadBuilder of(CloudEventsPayload template)
      create builder for CloudEventsPayload instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder