Class DefaultDocumentFactoryRegistry

java.lang.Object
eu.cloudnetservice.driver.document.defaults.DefaultDocumentFactoryRegistry
All Implemented Interfaces:
DocumentFactoryRegistry

@Singleton @Provides(DocumentFactoryRegistry.class) final class DefaultDocumentFactoryRegistry extends Object implements DocumentFactoryRegistry
The default implementation of a document factory.
Since:
4.0
  • Field Details

  • Constructor Details

    • DefaultDocumentFactoryRegistry

      private DefaultDocumentFactoryRegistry()
      Sealed constructor as this constructor should only get accessed from the injector. The constructor auto registers the json and empty document factory.
  • Method Details

    • documentFactories

      Get an unmodifiable view of all registered document factories.
      Specified by:
      documentFactories in interface DocumentFactoryRegistry
      Returns:
      an unmodifiable view of all registered document factories.
    • documentFactory

      @NonNull public @NonNull DocumentFactory documentFactory(@NonNull @NonNull String formatName)
      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.
      Specified by:
      documentFactory in interface DocumentFactoryRegistry
      Parameters:
      formatName - the name of the format to get.
      Returns:
      the document factory associated with the given format name.
    • findDocumentFactory

      @Nullable public @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.
      Specified by:
      findDocumentFactory in interface DocumentFactoryRegistry
      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.
    • unregisterDocumentFactory

      @Nullable public @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.
      Specified by:
      unregisterDocumentFactory in interface DocumentFactoryRegistry
      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.
    • registerDocumentFactory

      public 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.
      Specified by:
      registerDocumentFactory in interface DocumentFactoryRegistry
      Parameters:
      factory - the document factory to register if no mapping previously existed.
    • replaceDocumentFactory

      @Nullable public @Nullable DocumentFactory replaceDocumentFactory(@NonNull @NonNull DocumentFactory factory)
      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.
      Specified by:
      replaceDocumentFactory in interface DocumentFactoryRegistry
      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.