private boolean matchesArgMap(Map argMap) {
// first pass: named matchers
for (int i = 0; i < argConstraints.size(); i++) {
Object name = argNames.get(i);
if (name.equals("_")) continue;
IArgumentConstraint matcher = argConstraints.get(i);
if (!argMap.containsKey(name) || !matcher.isSatisfiedBy(argMap.remove(name)))
return false;
}
// second pass: unnamed matchers
nextMatcher:
for (int i = 0; i < argConstraints.size(); i++) {
Object name = argNames.get(i);
if (!name.equals("_")) continue;
IArgumentConstraint matcher = argConstraints.get(i);
@SuppressWarnings("unchecked")
Iterator<Object> argIter = argMap.values().iterator();
while (argIter.hasNext())
if (matcher.isSatisfiedBy(argIter.next())) {
argIter.remove();
continue nextMatcher;
}
return false;