5353 * @author Curtis Rueden
5454 */
5555@ Plugin (type = Service .class )
56- public class DefaultOpMatchingService extends AbstractService implements OpMatchingService {
56+ public class DefaultOpTypeMatchingService extends AbstractService implements OpTypeMatchingService {
5757
5858 @ Parameter
5959 private Context context ;
@@ -64,19 +64,17 @@ public class DefaultOpMatchingService extends AbstractService implements OpMatch
6464 // -- OpMatchingService methods --
6565
6666 @ Override
67- public OpCandidate findMatch (final OpEnvironment ops , final OpRef ref ) {
67+ public MatchingResult findMatch (final OpEnvironment ops , final OpRef ref ) {
6868 return findMatch (ops , Collections .singletonList (ref ));
6969 }
7070
7171 @ Override
72- public OpCandidate findMatch (final OpEnvironment ops , final List <OpRef > refs ) {
72+ public MatchingResult findMatch (final OpEnvironment ops , final List <OpRef > refs ) {
7373 // find candidates with matching name & type
7474 final List <OpCandidate > candidates = findCandidates (ops , refs );
7575 assertCandidatesFound (candidates , refs .get (0 ));
7676 // narrow down candidates to the exact matches
77- final List <OpCandidate > matches = filterMatches (candidates );
78-
79- return singleMatch (candidates , matches );
77+ return new MatchingResult (candidates , filterMatches (candidates ));
8078 }
8179
8280 @ Override
@@ -354,44 +352,6 @@ private int findCastLevels(final OpCandidate candidate, final Type[] paddedArgs)
354352 return level ;
355353 }
356354
357- /**
358- * Extracts and returns the single match from the given list of matches. If
359- * there is not exactly one match, an {@link IllegalArgumentException} is
360- * thrown with an analysis of the problem(s).
361- * <p>
362- * Helper method of {@link #findMatch}.
363- * </p>
364- *
365- * @param candidates
366- * The original unfiltered list of candidates, used during the
367- * analysis if there was a problem finding exactly one match.
368- * @param matches
369- * The list of matching candidates.
370- * @return The single matching candidate, with its module initialized.
371- * @throws IllegalArgumentException
372- * If there is not exactly one matching candidate.
373- */
374- private OpCandidate singleMatch (final List <OpCandidate > candidates , final List <OpCandidate > matches ) {
375- if (matches .size () == 1 ) {
376- // a single match: initialize and return it
377- OpCandidate match = matches .get (0 );
378- if (log .isDebug ()) {
379- log .debug ("Selected '" + match .getRef ().getLabel () + "' op: " + match .opInfo ().opClass ().getName ());
380- }
381-
382- // // initialize the op, if appropriate
383- // if (m.object() instanceof Initializable) {
384- // ((Initializable) m.object()).initialize();
385- // }
386-
387- return matches .get (0 );
388- }
389-
390- // final String analysis = OpUtils.matchInfo(candidates, matches);
391- // TODO
392- throw new IllegalArgumentException ("TODO dump analysis" );
393- }
394-
395355 /**
396356 * Verifies that the given candidate's module is valid.
397357 * <p>
0 commit comments