- All Superinterfaces:
io.cloudevents.rw.CloudEventContextWriter,io.cloudevents.rw.CloudEventWriter<io.cloudevents.CloudEvent>
- All Known Implementing Classes:
BaseCloudEventBuilder,CloudEventBuilder,CloudEventBuilder
@ParametersAreNullableByDefault
public interface CloudEventBuilder
extends io.cloudevents.rw.CloudEventWriter<io.cloudevents.CloudEvent>
Builder interface to build a
CloudEvent.-
Method Summary
Modifier and TypeMethodDescriptionio.cloudevents.CloudEventbuild()Build the eventstatic CloudEventBuilderfrom(io.cloudevents.CloudEvent event) Create a new builder starting from the values of the provided event.static CloudEventBuilderfromContext(io.cloudevents.CloudEventContext context) Create a new builder starting from the values of the provided context.static CloudEventBuilderfromSpecVersion(io.cloudevents.SpecVersion version) Create a new builder for the specifiedSpecVersionCopy this builder, creating a new instance with same values.static CloudEventBuilderv03()static CloudEventBuilderv03(io.cloudevents.CloudEvent event) static CloudEventBuilderv1()static CloudEventBuilderv1(io.cloudevents.CloudEvent event) withData(byte[] data) Set thedataof the eventwithData(io.cloudevents.CloudEventData data) Set thedataof the eventSet thedatacontenttypeanddataof the eventSet thedatacontenttypeanddataof the eventSet thedatacontenttype,dataschemaanddataof the eventSet thedatacontenttype,dataschemaanddataof the eventwithDataContentType(String dataContentType) Set thedatacontenttypeof the eventwithDataSchema(URI dataSchema) Set thedataschemaof the event.withExtension(io.cloudevents.CloudEventExtension extension) Add to the builder all the extension key/values of the provided extensionwithExtension(String key, byte[] value) Set an extension with provided key and binary valuewithExtension(String key, Boolean value) Set an extension with provided key and boolean valuewithExtension(String key, Number value) Set an extension with provided key and numeric valuewithExtension(String key, String value) Set an extension with provided key and string valuewithExtension(String key, URI value) Set an extension with provided key and uri valuewithExtension(String key, OffsetDateTime value) Set an extension with provided key and boolean valueSet theidof the eventRemove thedatacontenttype,dataschemaanddatafrom the eventRemove thedatacontenttypefrom the eventRemove thedataschemafrom the eventwithoutExtension(io.cloudevents.CloudEventExtension extension) Remove from the the builder the provided extension, if anywithoutExtension(String key) Remove from the the builder the provided extension key, if anywithSource(URI source) Set thesourceof the eventwithSubject(String subject) Set thesubjectof the eventwithTime(OffsetDateTime time) Set thetimeof the eventSet thetypeof the eventMethods inherited from interface io.cloudevents.rw.CloudEventContextWriter
withContextAttribute, withContextAttribute, withContextAttribute, withContextAttribute, withContextAttribute, withContextAttribute, withContextAttributeMethods inherited from interface io.cloudevents.rw.CloudEventWriter
end, end
-
Method Details
-
withId
Set theidof the event- Parameters:
id- id of the event- Returns:
- self
-
withSource
Set thesourceof the event- Parameters:
source- source of the event- Returns:
- self
-
withType
Set thetypeof the event- Parameters:
type- type of the event- Returns:
- self
-
withDataSchema
Set thedataschemaof the event. For CloudEvent v0.3, this will configure theschemaurlattribute.- Parameters:
dataSchema- dataschema of the event- Returns:
- self
-
withDataContentType
Set thedatacontenttypeof the event- Parameters:
dataContentType- datacontenttype of the event- Returns:
- self
-
withSubject
Set thesubjectof the event- Parameters:
subject- subject of the event- Returns:
- self
-
withTime
Set thetimeof the event- Parameters:
time- time of the event- Returns:
- self
-
withData
Set thedataof the event- Parameters:
data- data of the event- Returns:
- self
-
withData
Set thedatacontenttypeanddataof the event- Parameters:
dataContentType- datacontenttype of the eventdata- data of the event- Returns:
- self
-
withData
Set thedatacontenttype,dataschemaanddataof the event- Parameters:
dataContentType- datacontenttype of the eventdataSchema- dataschema of the eventdata- data of the event- Returns:
- self
-
withData
Set thedataof the event- Parameters:
data- data of the event- Returns:
- self
-
withData
Set thedatacontenttypeanddataof the event- Parameters:
dataContentType- datacontenttype of the eventdata- data of the event- Returns:
- self
-
withData
CloudEventBuilder withData(String dataContentType, URI dataSchema, io.cloudevents.CloudEventData data) Set thedatacontenttype,dataschemaanddataof the event- Parameters:
dataContentType- datacontenttype of the eventdataSchema- dataschema of the eventdata- data of the event- Returns:
- self
-
withoutData
CloudEventBuilder withoutData()Remove thedatacontenttype,dataschemaanddatafrom the event- Returns:
- self
-
withoutDataSchema
CloudEventBuilder withoutDataSchema()Remove thedataschemafrom the event- Returns:
- self
-
withoutDataContentType
CloudEventBuilder withoutDataContentType()Remove thedatacontenttypefrom the event- Returns:
- self
-
withExtension
Set an extension with provided key and string value- Parameters:
key- key of the extension attributevalue- value of the extension attribute- Returns:
- self
-
withExtension
Set an extension with provided key and numeric value- Parameters:
key- key of the extension attributevalue- value of the extension attribute- Returns:
- self
-
withExtension
Set an extension with provided key and boolean value- Parameters:
key- key of the extension attributevalue- value of the extension attribute- Returns:
- self
-
withExtension
Set an extension with provided key and uri value- Parameters:
key- key of the extension attributevalue- value of the extension attribute- Returns:
- self
-
withExtension
Set an extension with provided key and boolean value- Parameters:
key- key of the extension attributevalue- value of the extension attribute- Returns:
- self
-
withExtension
Set an extension with provided key and binary value- Parameters:
key- key of the extension attributevalue- value of the extension attribute- Returns:
- self
-
withExtension
Add to the builder all the extension key/values of the provided extension- Parameters:
extension- materialized extension to set in the builder- Returns:
- self
-
withoutExtension
Remove from the the builder the provided extension key, if any- Parameters:
key- key of the extension attribute- Returns:
- self
-
withoutExtension
Remove from the the builder the provided extension, if any- Parameters:
extension- materialized extension to remove from the builder- Returns:
- self
-
build
Build the event- Returns:
- the built event
- Throws:
IllegalStateException- if a required attribute is not configured
-
newBuilder
CloudEventBuilder newBuilder()Copy this builder, creating a new instance with same values.- Returns:
- A new builder with same values of this instance
-
v1
- Returns:
- a new CloudEvent v1 builder
-
v1
- Parameters:
event- event to bootstrap the builder- Returns:
- a new CloudEvent v1 builder filled with content of
event
-
v03
- Returns:
- a new CloudEvent v0.3 builder
-
v03
- Parameters:
event- event to bootstrap the builder- Returns:
- a new CloudEvent v0.3 builder filled with content of
event
-
fromSpecVersion
Create a new builder for the specifiedSpecVersion- Parameters:
version- version to use for the new builder- Returns:
- a new builder
-
from
Create a new builder starting from the values of the provided event.- Parameters:
event- event to copy values from- Returns:
- the new builder
-
fromContext
Create a new builder starting from the values of the provided context.- Parameters:
context- context to copy values from- Returns:
- the new builder
-