# determineHighestPriorityCandidate method

1. @protected

String? determineHighestPriorityCandidate(

1. Map<String, Object> candidates,
2. Class requiredType

)

Determines the highest priority candidate from multiple options.

This method evaluates the priority of each candidate and selects the one with the highest priority (lowest numerical value). If multiple candidates have the same highest priority, it indicates a conflict.

`candidates` the map of candidate pod names to instances `requiredType` the type of dependency being resolved

Returns the highest priority candidate name, or throws an exception if conflict exists

## Implementation

    @protected
    String? determineHighestPriorityCandidate(Map<String, Object> candidates, Class requiredType) {
      String? highestPrioritizedName;
    		int? highestPriority;
    		bool highestPriorityConflictDetected = false;

      for (final entry in candidates.entries) {
    			String candidate = entry.key;
    			Object instance = entry.value;

    			int? candidatePriority = getPriority(instance);
        if (candidatePriority != null) {
          if (highestPriority != null) {
            if (candidatePriority.equals(highestPriority)) {
              highestPriorityConflictDetected = true;
            } else if (candidatePriority < highestPriority) {
              highestPrioritizedName = candidate;
              highestPriority = candidatePriority;
              highestPriorityConflictDetected = false;
            }
          } else {
            highestPrioritizedName = candidate;
            highestPriority = candidatePriority;
          }
        }
    		}

      if (highestPriorityConflictDetected) {
    			return notifyMultipleCandidatesFound(requiredType, candidates);
    		}

    		return highestPrioritizedName;
    }