Interface IdGeneratorProvider
- All Known Implementing Classes:
 DefaultIdGeneratorProvider
IdGenerator instances.
 
 This interface provides a registry for ID generators that can be accessed by name throughout an application. It supports both named generators and a special shared generator that can be used as a default.
The provider acts as a centralized repository for ID generators, enabling:
- Dependency injection of named generators
 - Centralized configuration and management
 - Easy switching between different generator implementations
 - Sharing of a common generator across multiple components
 
Common use cases include:
- Managing different ID generators for different entity types
 - Providing a default generator for components that don't specify one
 - Enabling runtime configuration of ID generation strategies
 
Implementations of this interface are expected to be thread-safe and can be used concurrently across multiple threads.
- 
Field Summary
Fields - 
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all registered ID generators.entries()Get all registered ID generator entries.Get an ID generator by its name.getAll()Get all registered ID generators.default IdGeneratorgetRequired(String name) Get an ID generator by its name, throwing an exception if not found.getShare()Get the shared (default) ID generator.Remove an ID generator by its name.Remove the shared (default) ID generator.voidset(String name, IdGenerator idGenerator) Set an ID generator with the specified name.voidsetShare(IdGenerator idGenerator) Set the shared (default) ID generator. 
- 
Field Details
- 
SHARE
The key used for the shared (default) ID generator.This constant defines the name used to access the shared ID generator, which serves as a default generator for components that don't require a specific named generator.
- See Also:
 
 
 - 
 - 
Method Details
- 
get
Get an ID generator by its name.This method returns an optional containing the ID generator with the specified name, or an empty optional if no generator with that name exists.
- Parameters:
 name- The name of the ID generator to retrieve- Returns:
 - An optional containing the ID generator, or empty if not found
 
 - 
getRequired
Get an ID generator by its name, throwing an exception if not found.This method returns the ID generator with the specified name, or throws an
IllegalArgumentExceptionif no generator with that name exists.- Parameters:
 name- The name of the ID generator to retrieve- Returns:
 - The ID generator with the specified name
 - Throws:
 IllegalArgumentException- if no generator with the specified name exists
 - 
set
Set an ID generator with the specified name.This method registers an ID generator with the specified name, replacing any existing generator with the same name.
- Parameters:
 name- The name to register the generator underidGenerator- The ID generator to register
 - 
remove
Remove an ID generator by its name.This method removes the ID generator with the specified name and returns the removed generator, or null if no generator with that name existed.
- Parameters:
 name- The name of the ID generator to remove- Returns:
 - The removed ID generator, or null if not found
 
 - 
clear
void clear()Clear all registered ID generators.This method removes all registered ID generators, including the shared generator, leaving the provider empty.
 - 
entries
Set<Map.Entry<String,IdGenerator>> entries()Get all registered ID generator entries.This method returns a set of map entries representing all registered ID generators, including their names and instances.
- Returns:
 - A set of entries for all registered ID generators
 
 - 
getAll
Collection<IdGenerator> getAll()Get all registered ID generators.This method returns a collection of all registered ID generator instances, without their associated names.
- Returns:
 - A collection of all registered ID generators