SimplePodDefinitionRegistry class

A basic registry for managing pod definitions.

This registry stores and retrieves PodDefinitions by name.
It provides the ability to:

  • Register new pod definitions.
  • Look up existing pod definitions.
  • Check if a pod definition exists.
  • Remove pod definitions.
  • Track the total count and names of registered definitions.
  • Handle conflicts with alias names inherited from SimpleAliasRegistry.

This is commonly used as the backbone for dependency injection containers, where pods must be defined before they can be instantiated.

Example usage:

void main() {
  final registry = SimplePodDefinitionRegistry();

  // Create a simple pod definition (hypothetical).
  final userPod = PodDefinition('UserPod');

  // Register it.
  registry.registerDefinition('user', userPod);

  // Retrieve it.
  final retrieved = registry.getDefinition('user');
  print(retrieved?.name); // Output: UserPod

  // Check existence.
  print(registry.containsDefinition('user')); // true

  // Get total count.
  print(registry.getDefinitionCount()); // 1

  // Remove definition.
  registry.removeDefinition('user');

  // Accessing a removed pod throws an exception.
  try {
    registry.getDefinition('user');
  } catch (e) {
    print(e); // NoSuchPodDefinitionException: No pod named 'user' is defined
  }
}
Inheritance
Implemented types

Constructors

SimplePodDefinitionRegistry()
A basic registry for managing pod definitions.

Properties

aliasCount → int
Returns the number of registered aliases for the current thread.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
Returns true if no aliases are registered for the current thread.
no setterinherited
isNotEmpty → bool
Returns true if aliases are registered for the current thread.
no setterinherited
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 setterinherited
threadLocalAliasNames → List<String>
Gets the thread-local alias names list for testing or advanced use cases.
no setterinherited

Methods

allowAliasOverriding() → bool
Determine whether alias overriding is allowed.
inherited
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.
inherited
clear() → void
Clears all alias registrations for the current thread.
inherited
containsDefinition(String name) → bool
Returns true if this registry contains a pod with the given name.
override
getAlias(String name) → String?
Retrieves the primary name associated with the given alias.
inherited
getAliases(String name) → List<String>
Retrieves all aliases registered for the given primary name.
inherited
getAliasNames() → List<String>
Returns all registered aliases as an unmodifiable view for the current thread.
inherited
getDefinition(String name) → PodDefinition
Retrieve the pod registered under name.
override
getDefinitionByClass(Class type) → PodDefinition
Returns the pod definition for the specified class type.
override
getDefinitionNames() → List<String>
Returns a list of all pod names currently registered.
override
getNumberOfPodDefinitions() → int
Returns the total number of pods registered.
override
getUltimateNames() → List<String>
Returns all registered target names as an unmodifiable view for the current thread.
inherited
hasAlias(String name, String alias) → bool
Determine whether the given name has the given alias registered.
inherited
isAlias(String name) → bool
Checks whether the given name is registered as an alias.
inherited
isNameInUse(String name) → Future<bool>
Returns true if name is currently in use in this registry.
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.
inherited
registerDefinition(String name, PodDefinition pod) → Future<void>
Register a new pod under the given name.
override
removeAlias(String alias) → void
Removes an alias from the registry.
inherited
removeDefinition(String name) → Future<void>
Remove the pod associated with name.
override
resolveAliases(String valueResolver(String)) → void
Resolve all alias target names and aliases registered in this registry, applying the given StringValueResolver to them.
inherited
targetName(String name) → String
Determine the target name, resolving aliases to their ultimate target.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited