SimpleAliasRegistry class
A thread-safe implementation of AliasRegistry using LocalThread storage.
This implementation maintains separate alias mappings for each thread with support for:
- Alias overriding control
- Circular reference detection
- Alias resolution and canonical name resolution
- Thread-local storage using ThreadLocal
Key Features:
- Thread-safe alias management using ThreadLocal
- Support for alias chains and transitive alias resolution
- Configurable alias overriding behavior
- Circular reference detection during registration
- Efficient thread-local alias lookup and management
Storage Structure (per thread):
_aliasMap: Map of alias → canonical name mappings_aliasNames: List of alias names in registration order
Usage Example:
final registry = SimpleAliasRegistry();
// Register aliases in the current thread
registry.registerAlias('userService', 'userManager');
registry.registerAlias('userService', 'accountService');
// Check if a name is an alias
print(registry.isAlias('userManager')); // true
// Get all aliases for a name (including transitive aliases)
final aliases = registry.getAliases('userService');
print(aliases); // ['userManager', 'accountService']
// Resolve canonical name
print(registry.canonicalName('userManager')); // 'userService'
- Implemented types
- Implementers
Constructors
- SimpleAliasRegistry()
-
A thread-safe implementation of AliasRegistry using
LocalThreadstorage.
Properties
- aliasCount → int
-
Returns the number of registered aliases for the current thread.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Returns true if no aliases are registered for the current thread.
no setter
- isNotEmpty → bool
-
Returns true if aliases are registered for the current thread.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
threadLocalAliasMap
→ Map<
String, String> -
Gets the thread-local alias map for testing or advanced use cases.
no setter
-
threadLocalAliasNames
→ List<
String> -
Gets the thread-local alias names list for testing or advanced use cases.
no setter
Methods
-
allowAliasOverriding(
) → bool - Determine whether alias overriding is allowed.
-
checkForAliasCircle(
String name, String alias) → void - Check whether the given name points back to the given alias as an alias in the other direction already, catching a circular reference.
-
clear(
) → void - Clears all alias registrations for the current thread.
-
getAlias(
String name) → String? -
Retrieves the primary name associated with the given
alias.override -
getAliases(
String name) → List< String> -
Retrieves all aliases registered for the given primary
name.override -
getAliasNames(
) → List< String> - Returns all registered aliases as an unmodifiable view for the current thread.
-
getUltimateNames(
) → List< String> - Returns all registered target names as an unmodifiable view for the current thread.
-
hasAlias(
String name, String alias) → bool - Determine whether the given name has the given alias registered.
-
isAlias(
String name) → bool -
Checks whether the given
nameis registered as an alias.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerAlias(
String name, String alias) → void -
Registers an alias for an existing name in the registry.
override
-
removeAlias(
String alias) → void -
Removes an alias from the registry.
override
-
resolveAliases(
String valueResolver(String)) → void - Resolve all alias target names and aliases registered in this registry, applying the given StringValueResolver to them.
-
targetName(
String name) → String - Determine the target name, resolving aliases to their ultimate target.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited