// need to check if any of the types in $newMatch exist in $oldMatches
final Iterator<Map.Entry<Type, Match>> newMatchesIterator = newMatches.entrySet().iterator();
while (newMatchesIterator.hasNext()) {
final Map.Entry<Type, Match> entry = newMatchesIterator.next();
final Type newType = entry.getKey();
final Match newMatch = entry.getValue();
List<Match> listOfMatchesForType = (List<Match>) oldMatches.get(newType);
if (null == listOfMatchesForType) {
listOfMatchesForType = new ArrayList<Match>();
oldMatches.put(newType, listOfMatchesForType);
}
// only add if newMatch is not the same type as one of oldMatch's
final Type newMatchReaderOrWriter = newMatch.getReaderWriter();
final Iterator<Match> iterator = listOfMatchesForType.iterator();
boolean duplicate = false;
while (iterator.hasNext()) {
final Match otherMatch = iterator.next();
if (newMatchReaderOrWriter.equals(otherMatch.getReaderWriter())) {
duplicate = true;
break;
}
}