/** * Filters out candidates that pass the given filter. * <p> * Helper method of {@link #filterMatches(List)}. * </p> */ private List<OpCandidate> filterMatches(final List<OpCandidate> candidates, final Predicate<OpCandidate> filter) { final ArrayList<OpCandidate> matches = new ArrayList<>(); double priority = Double.NaN; for (final OpCandidate candidate : candidates) { final ModuleInfo info = candidate.cInfo(); final double p = info.getPriority(); if (p != priority && !matches.isEmpty()) { // NB: Lower priority was reached; stop looking for any more matches. break; } priority = p; if (filter.test(candidate) && moduleConforms(candidate)) { matches.add(candidate); } } return matches; }
/** * Extracts a list of candidates that requires casting to match with the * reference. * <p> * Helper method of {@link #filterMatches(List)}. * </p> */ private List<OpCandidate> castMatches(final List<OpCandidate> candidates) { final ArrayList<OpCandidate> matches = new ArrayList<>(); int minLevels = Integer.MAX_VALUE; double priority = Double.NaN; for (final OpCandidate candidate : candidates) { final ModuleInfo info = candidate.cInfo(); final double p = info.getPriority(); if (p != priority && !matches.isEmpty()) { // NB: Lower priority was reached; stop looking for any more matches. break; } priority = p; final int nextLevels = findCastLevels(candidate); if (nextLevels < 0 || nextLevels > minLevels) continue; if (!moduleConforms(candidate)) continue; if (nextLevels < minLevels) { matches.clear(); minLevels = nextLevels; } matches.add(candidate); } return matches; }
if (column == 7) return info.getPriority(); return null;
@Override public Module createModule(final ModuleInfo info) { final Module existing = getRegisteredModuleInstance(info); if (existing != null) return existing; try { final Module module = info.createModule(); getContext().inject(module); Priority.inject(module, info.getPriority()); return module; } catch (final ModuleException exc) { log.error("Cannot create module: " + info.getDelegateClassName(), exc); } return null; }
@Override public Module createModule(final ModuleInfo info) { final Module existing = getRegisteredModuleInstance(info); if (existing != null) return existing; try { final Module module = info.createModule(); getContext().inject(module); Priority.inject(module, info.getPriority()); return module; } catch (final ModuleException exc) { log.error("Cannot create module: " + info.getDelegateClassName(), exc); } return null; }