/** * Find the most preferred platform for a given capability from the list of * platforms. This does not use the map of preferred platforms. * * @param capability the capability * @return the most preferred platform, or null if no platform was found */ private synchronized @Nullable Platform findMostPreferred(Capability capability) { Platform preferred = null; Preference highest = null; for (Platform platform : platforms) { Preference preference = platform.getCapabilities().get(capability); if (preference != null && (highest == null || preference.isPreferredOver(highest))) { preferred = platform; highest = preference; } } return preferred; }