Class EventFormatProvider

java.lang.Object
io.cloudevents.core.provider.EventFormatProvider

@ParametersAreNonnullByDefault public final class EventFormatProvider extends Object
Singleton holding the discovered EventFormat implementations through ServiceLoader.

You can resolve an event format using EventFormatProvider.getInstance().resolveFormat(contentType).

You can programmatically add a new EventFormat implementation using registerFormat(EventFormat).

  • Method Details

    • getInstance

      public static EventFormatProvider getInstance()
      Returns:
      instance of EventFormatProvider
    • registerFormat

      public void registerFormat(EventFormat format)
      Register a new EventFormat programmatically.
      Parameters:
      format - the new format to register
    • getContentTypes

      public Set<String> getContentTypes()
      Enumerate the supported content types.
      Returns:
      an alphabetically sorted list of content types
    • resolveFormat

      @Nullable public EventFormat resolveFormat(String contentType)
      Resolve an event format starting from the content type.
      Parameters:
      contentType - the content type to resolve the event format
      Returns:
      null if no format was found for the provided content type
    • resolveFormat

      @Nullable public EventFormat resolveFormat(ContentType contentType)
      Resolve an event format starting from the content type.
      Parameters:
      contentType - the content type to resolve the event format
      Returns:
      null if no format was found for the provided content type