Interface DocumentFactoryRegistry

All Known Implementing Classes:
DefaultDocumentFactoryRegistry

public interface DocumentFactoryRegistry
A registry for document factories. Any custom document factory should get registered to this factory. By default, the following standard factories are registered:
  1. json
  2. empty

This registry is primarily used when documents are transferred via the network to decode the document type on the receiving network component.

Since:
4.0
  • Method Details

    • documentFactories

      Get an unmodifiable view of all registered document factories.
      Returns:
      an unmodifiable view of all registered document factories.
    • documentFactory

      Get the document factory with the given format name. This method never returns null and throws an exception if no format with the given name is registered. Note: the format name is case-sensitive.
      Parameters:
      formatName - the name of the format to get.
      Returns:
      the document factory associated with the given format name.
      Throws:
      NullPointerException - if the given format name is null or no factory for the given format is registered.
    • findDocumentFactory

      @Nullable @Nullable DocumentFactory findDocumentFactory(@NonNull @NonNull String formatName)
      Tries to find the document factory with the given format name. This method returns null if no document factory for the given format name is registered. Note: the format name is case-sensitive.
      Parameters:
      formatName - the name of the format to get.
      Returns:
      the document factory associated with the given format name or null if no factory is associated.
      Throws:
      NullPointerException - if the given format name is null.
    • unregisterDocumentFactory

      @Nullable @Nullable DocumentFactory unregisterDocumentFactory(@NonNull @NonNull String formatName)
      Unregisters the document factory that is associated with the given format name, returning the associated factory. This method returns null if no factory was associated with the given format name. Note: the format name is case-sensitive.
      Parameters:
      formatName - the name of format to unregister.
      Returns:
      the document factory that was associated with the given format name or null if no factory was associated.
      Throws:
      NullPointerException - if the given format name is null.
    • registerDocumentFactory

      void registerDocumentFactory(@NonNull @NonNull DocumentFactory factory)
      Associates the format name of the given document factory if no factory is already associated with the given factory. Note: the format name is case-sensitive.
      Parameters:
      factory - the document factory to register if no mapping previously existed.
      Throws:
      NullPointerException - if the given document factory is null.
    • replaceDocumentFactory

      Associates the format name of the given document factory with the given factory. If a mapping previously existed then the existing registered factory gets replaced and the method returns the old factory. Note: the format name is case-sensitive.
      Parameters:
      factory - the document factory to register if no mapping previously existed.
      Returns:
      the document factory that was previously associated with the format name or null if no mapping existed.
      Throws:
      NullPointerException - if the given document factory is null.