* @param difference
* The difference to which all indexes will be added, not null
*/
protected void setBestMatchingIndexes(ArrayList<Integer> leftIndexes, ArrayList<Integer> rightIndexes,
UnorderedCollectionDifference difference) {
MatchingScoreCalculator matchingScoreCalculator = createMatchingScoreCalculator();
Map<Integer, Map<Integer, Difference>> differences = difference.getElementDifferences();
for (Integer leftIndex : leftIndexes) {
int score = Integer.MAX_VALUE;
for (Integer rightIndex : rightIndexes) {
Difference elementDifference = differences.get(leftIndex).get(rightIndex);
int matchingScore = matchingScoreCalculator.calculateMatchingScore(elementDifference);
if (matchingScore < score) {
score = matchingScore;
difference.setBestMatchingIndexes(leftIndex, rightIndex);
}
}