# determineAutowireCandidate method

1. @protected

String? determineAutowireCandidate(

1. Map<String, Object> candidates,
2. DependencyDescriptor descriptor

)

Determines the best autowire candidate from multiple options.

This method applies various strategies to select the most appropriate candidate when multiple pods satisfy a dependency requirement:

1. Primary candidate
2. Name matching
3. Highest priority candidate
4. Resolvable dependency

`candidates` the map of candidate pod names to instances `descriptor` the dependency descriptor

Returns the selected candidate name, or `null` if no candidate can be determined

## Implementation

    @protected
    String? determineAutowireCandidate(Map<String, Object> candidates, DependencyDescriptor descriptor) {
      String? candidate = determinePrimaryCandidate(candidates.keys.toList());
      if (candidate != null) {
        return candidate;
      }

      candidate = candidates.keys.find((c) => matchesName(c, descriptor.podName));
      if (candidate != null) {
        return candidate;
      }

      candidate = candidates.keys.find((c) => matchesName(c, descriptor.propertyName));
      if (candidate != null) {
        return candidate;
      }

      candidate = determineHighestPriorityCandidate(candidates, descriptor.type);
      if (candidate != null) {
        return candidate;
      }

      candidate = candidates.entries.find((e) => _resolvableDependencies.containsValue(e.value))?.key;
      if (candidate != null) {
        return candidate;
      }

      return null;
    }