Class ToCloudEventTransformerSpec

java.lang.Object
org.springframework.integration.cloudevents.dsl.ToCloudEventTransformerSpec

public class ToCloudEventTransformerSpec extends Object
Since:
7.1
Author:
Glenn Renfro, Artem Bilan
  • Field Details

  • Constructor Details

    • ToCloudEventTransformerSpec

      protected ToCloudEventTransformerSpec()
      Create an instance with no extension patterns.
    • ToCloudEventTransformerSpec

      protected ToCloudEventTransformerSpec(String... extensionPatterns)
      Create an instance with the provided extension patterns.

      Extension patterns are used to match message headers that should be included as CloudEvent extensions. Patterns support wildcards (e.g., "myapp.*").

      Parameters:
      extensionPatterns - patterns to evaluate whether message headers should be added as extensions to the CloudEvent.
  • Method Details

    • eventFormat

      public ToCloudEventTransformerSpec eventFormat(io.cloudevents.core.format.EventFormat eventFormat)
      Set the EventFormat to use for CloudEvent serialization.

      If eventFormat and the eventFormatContentTypeExpression are provided, the eventFormat has precedence.

      Parameters:
      eventFormat - the event format for serializing CloudEvents
      Returns:
      the spec for method chaining
    • eventIdExpression

      public ToCloudEventTransformerSpec eventIdExpression(String eventIdExpression)
      Set the SpEL expression to create CloudEvent id.

      Default is to extract the id from the MessageHeaders of the message.

      Parameters:
      eventIdExpression - the SpEL expression to create the id for each CloudEvent
      Returns:
      the spec
    • eventIdFunction

      public ToCloudEventTransformerSpec eventIdFunction(Function<Message<?>, String> eventIdFunction)
      Set the Function to create CloudEvent id.

      Default is to extract the id from the MessageHeaders of the message.

      Parameters:
      eventIdFunction - the Function to create the id for each CloudEvent
      Returns:
      the spec
    • eventIdExpression

      public ToCloudEventTransformerSpec eventIdExpression(Expression eventIdExpression)
      Set the Expression to create CloudEvent id.

      Default is to extract the id from the MessageHeaders of the message.

      Parameters:
      eventIdExpression - the expression to create the id for each CloudEvent
      Returns:
      the spec
    • sourceExpression

      public ToCloudEventTransformerSpec sourceExpression(String sourceExpression)
      Set the SpEL expression to create CloudEvent source.

      Default is "/spring/" + appName + "." + getBeanName()).

      Parameters:
      sourceExpression - the SpEL expression to create the source for each CloudEvent
      Returns:
      the spec
    • sourceFunction

      public ToCloudEventTransformerSpec sourceFunction(Function<Message<?>, URI> sourceFunction)
      Set the Function to create CloudEvent source.

      Default is "/spring/" + appName + "." + getBeanName()).

      Parameters:
      sourceFunction - the Function to create the source for each CloudEvent
      Returns:
      the spec
    • source

      public ToCloudEventTransformerSpec source(URI source)
      Set the CloudEvent source.

      Default is "/spring/" + appName + "." + getBeanName()).

      Parameters:
      source - the source for each CloudEvent
      Returns:
      the spec
    • sourceExpression

      public ToCloudEventTransformerSpec sourceExpression(Expression sourceExpression)
      Set the Expression to create CloudEvent source.

      Default is "/spring/" + appName + "." + getBeanName()).

      Parameters:
      sourceExpression - the expression to create the source for each CloudEvent
      Returns:
      the spec
    • typeExpression

      public ToCloudEventTransformerSpec typeExpression(String typeExpression)
      Set the SpEL expression to extract the type for the CloudEvent.
      Parameters:
      typeExpression - the SpEL expression to create the type for each CloudEvent

      Default is spring.message.

      Returns:
      the spec
    • typeFunction

      public ToCloudEventTransformerSpec typeFunction(Function<Message<?>, String> typeFunction)
      Set the Function to extract the type for the CloudEvent.
      Parameters:
      typeFunction - the Function to create the type for each CloudEvent

      Default is spring.message.

      Returns:
      the spec
    • type

      public ToCloudEventTransformerSpec type(String type)
      Set the type for the CloudEvent.
      Parameters:
      type - the type for each CloudEvent

      Default is spring.message.

      Returns:
      the spec
    • typeExpression

      public ToCloudEventTransformerSpec typeExpression(Expression typeExpression)
      Set the Expression to extract the type for the CloudEvent.
      Parameters:
      typeExpression - the expression to create the type for each CloudEvent

      Default is spring.message.

      Returns:
      the spec
    • dataSchemaExpression

      public ToCloudEventTransformerSpec dataSchemaExpression(String dataSchemaExpression)
      Set the SpEL expression to create the dataSchema for the CloudEvent.
      Parameters:
      dataSchemaExpression - the SpEL expression to create the dataSchema for each CloudEvent
      Returns:
      the spec
    • dataSchemaFunction

      public ToCloudEventTransformerSpec dataSchemaFunction(Function<Message<?>, URI> dataSchemaFunction)
      Set the Function to create the dataSchema for the CloudEvent.
      Parameters:
      dataSchemaFunction - the Function to create the dataSchema for each CloudEvent
      Returns:
      the spec
    • dataSchema

      public ToCloudEventTransformerSpec dataSchema(URI dataSchema)
      Set the dataSchema for the CloudEvent.
      Parameters:
      dataSchema - the dataSchema for each CloudEvent
      Returns:
      the spec
    • dataSchemaExpression

      public ToCloudEventTransformerSpec dataSchemaExpression(Expression dataSchemaExpression)
      Set the Expression to create the dataSchema for the CloudEvent.
      Parameters:
      dataSchemaExpression - the expression to create the dataSchema for each CloudEvent
      Returns:
      the spec
    • subjectExpression

      public ToCloudEventTransformerSpec subjectExpression(String subjectExpression)
      Set the SpEL expression to create the subject for the CloudEvent.
      Parameters:
      subjectExpression - the SpEL expression to create the subject for each CloudEvent
      Returns:
      the spec
    • subjectFunction

      public ToCloudEventTransformerSpec subjectFunction(Function<Message<?>, String> subjectFunction)
      Set the Function to create the subject for the CloudEvent.
      Parameters:
      subjectFunction - the Function to create the subject for each CloudEvent
      Returns:
      the spec
    • subject

      public ToCloudEventTransformerSpec subject(String subject)
      Set the subject for the CloudEvent.
      Parameters:
      subject - the subject for each CloudEvent
      Returns:
      the spec
    • subjectExpression

      public ToCloudEventTransformerSpec subjectExpression(Expression subjectExpression)
      Set the Expression to create the subject for the CloudEvent.
      Parameters:
      subjectExpression - the expression to create the subject for each CloudEvent
      Returns:
      the spec
    • eventFormatContentTypeExpression

      public ToCloudEventTransformerSpec eventFormatContentTypeExpression(String eventFormatContentTypeExpression)
      Set the SpEL expression to produce a cloud event format content type when EventFormatProvider is to be used to determine EventFormat.

      If eventFormat and the eventFormatContentTypeExpression are provided, the eventFormat has precedence.

      Parameters:
      eventFormatContentTypeExpression - the SpEL expression to evaluate a content type for the EventFormatProvider.resolveFormat(String)
      Returns:
      the spec
    • eventFormatContentTypeFunction

      public ToCloudEventTransformerSpec eventFormatContentTypeFunction(Function<Message<?>, String> eventFormatContentTypeFunction)
      Set the Function to produce a cloud event format content type when EventFormatProvider is to be used to determine EventFormat.

      If eventFormat and the eventFormatContentTypeExpression are provided, the eventFormat has precedence.

      Parameters:
      eventFormatContentTypeFunction - the Function to evaluate a content type for the EventFormatProvider.resolveFormat(String)
      Returns:
      the spec
    • eventFormatContentType

      public ToCloudEventTransformerSpec eventFormatContentType(String eventFormatContentType)
      Set the cloud event format content type when EventFormatProvider is to be used to determine EventFormat.

      If eventFormat and the eventFormatContentType are provided, the eventFormat has precedence.

      Parameters:
      eventFormatContentType - the Function to evaluate a content type for the EventFormatProvider.resolveFormat(String)
      Returns:
      the spec
    • eventFormatContentTypeExpression

      public ToCloudEventTransformerSpec eventFormatContentTypeExpression(Expression eventFormatContentTypeExpression)
      Set the Expression to produce a cloud event format content type when EventFormatProvider is to be used to determine EventFormat.

      If eventFormat and the eventFormatContentTypeExpression are provided, the eventFormat has precedence.

      Parameters:
      eventFormatContentTypeExpression - the Expression to evaluate a content type for the EventFormatProvider.resolveFormat(String)
      Returns:
      the spec
    • cloudEventPrefix

      public ToCloudEventTransformerSpec cloudEventPrefix(String cloudEventPrefix)
      Set the prefix for CloudEvent headers in binary content mode.

      Default is CloudEventHeaders.PREFIX.

      Parameters:
      cloudEventPrefix - the prefix to use for CloudEvent headers
      Returns:
      the spec
    • get

      Get the ToCloudEventTransformer instance created and configured by this builder.

      This method provides access to the transformer for advanced configuration or direct use outside the DSL context.

      Returns:
      the configured ToCloudEventTransformer