# resolveAliases method

1. @protected

void resolveAliases(

1. String valueResolver(
   1. String
   )

)

Resolve all alias target names and aliases registered in this registry, applying the given StringValueResolver to them.

The value resolver may for example resolve placeholders in target pod names and even in alias names. This is useful for processing aliases that contain placeholders that need to be resolved at runtime.

## Parameters:

- `valueResolver`: A function that resolves string values (e.g., placeholders)

## Throws:

- IllegalStateException if resolution would cause conflicts

## Example:

    final registry = SimpleAliasRegistry();
    registry.registerAlias('${database.service}', '${db.alias}');

    // Resolve placeholders
    registry.resolveAliases((value) {
      if (value == '${database.service}') return 'mysqlService';
      if (value == '${db.alias}') return 'database';
      return value;
    });

    // Now aliases are resolved
    print(registry.getAlias('database')); // 'mysqlService'

## Implementation

    @protected
    void resolveAliases(String Function(String) valueResolver) {
      return synchronized(this, () {
        final aliasMap = _getAliasMap();
        final aliasNames = _getAliasNames();
        final aliasNamesCopy = List<String>.from(aliasNames);

        for (final alias in aliasNamesCopy) {
          final registeredName = aliasMap[alias];
          if (registeredName != null) {
            final resolvedAlias = valueResolver(alias);
            final resolvedName = valueResolver(registeredName);

            if (resolvedAlias.isEmpty || resolvedName.isEmpty || resolvedAlias == resolvedName) {
              aliasMap.remove(alias);
              aliasNames.remove(alias);
            } else if (resolvedAlias != alias) {
              final existingName = aliasMap[resolvedAlias];
              if (existingName != null) {
                if (existingName == resolvedName) {
                  // Pointing to existing alias - just remove placeholder
                  aliasMap.remove(alias);
                  aliasNames.remove(alias);
                  continue;
                }
                throw IllegalStateException(
                  "Cannot register resolved alias '$resolvedAlias' (original: '$alias') "
                  "for name '$resolvedName': It is already registered for name '$existingName'."
                );
              }

              checkForAliasCircle(resolvedName, resolvedAlias);

              aliasMap.remove(alias);
              aliasNames.remove(alias);

              aliasMap[resolvedAlias] = resolvedName;
              aliasNames.add(resolvedAlias);
            } else if (registeredName != resolvedName) {
              aliasMap[alias] = resolvedName;
            }
          }
        }
      });
    }