# targetName method

1. @protected

String targetName(

1. String name

)

Determine the target name, resolving aliases to their ultimate target.

Follows alias chains recursively until it finds the ultimate target name that is not itself an alias of another name.

## Parameters:

- `name`: The name to resolve (can be an alias or target name)

## Returns:

The ultimate target name after resolving all aliases

## Example:

    final registry = SimpleAliasRegistry();
    registry.registerAlias('ultimateService', 'alias1');
    registry.registerAlias('alias1', 'alias2');
    registry.registerAlias('alias2', 'alias3');

    print(registry.targetName('alias3')); // 'ultimateService'
    print(registry.targetName('alias1')); // 'ultimateService'
    print(registry.targetName('ultimateService')); // 'ultimateService'

## Implementation

    @protected
    String targetName(String name) {
      return synchronized(this, () {
        final aliasMap = _getAliasMap();
        var targetName = name;
        String? resolvedName;

        do {
          resolvedName = aliasMap[targetName];
          if (resolvedName != null) {
            targetName = resolvedName;
          }
        } while (resolvedName != null);

        return targetName;
      });
    }