clear method

  1. @protected
void clear()

Clears all alias registrations for the current thread.

Removes all alias mappings and resets the registry to its initial state for the current thread. Other threads are unaffected.

Example:

final registry = SimpleAliasRegistry();
registry.registerAlias('service1', 'alias1');
registry.registerAlias('service2', 'alias2');

print(registry.aliasCount); // 2

registry.clear();

print(registry.aliasCount); // 0
print(registry.isEmpty); // true

Implementation

@protected
void clear() {
  return synchronized(this, () {
    final aliasMap = _getAliasMap();
    final aliasNames = _getAliasNames();
    aliasMap.clear();
    aliasNames.clear();
  });
}