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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSealed constructor as this constructor should only get accessed from the injector. -
Method Summary
Modifier and TypeMethodDescriptionGet an unmodifiable view of all registered document factories.documentFactory(@NonNull String formatName) Get the document factory with the given format name.findDocumentFactory(@NonNull String formatName) Tries to find the document factory with the given format name.voidAssociates the format name of the given document factory if no factory is already associated with the given factory.Associates the format name of the given document factory with the given factory.unregisterDocumentFactory(@NonNull String formatName) Unregisters the document factory that is associated with the given format name, returning the associated factory.
-
Field Details
-
registeredFactories
-
-
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:
documentFactoriesin interfaceDocumentFactoryRegistry- 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.- Specified by:
documentFactoryin interfaceDocumentFactoryRegistry- Parameters:
formatName- the name of the format to get.- Returns:
- the document factory associated with the given format name.
-
findDocumentFactory
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:
findDocumentFactoryin interfaceDocumentFactoryRegistry- 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:
unregisterDocumentFactoryin interfaceDocumentFactoryRegistry- 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
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:
registerDocumentFactoryin interfaceDocumentFactoryRegistry- 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:
replaceDocumentFactoryin interfaceDocumentFactoryRegistry- 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.
-