public class LenientOrderCollectionComparator extends Object implements Comparator
| Constructor and Description |
|---|
LenientOrderCollectionComparator() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canCompare(Object left,
Object right)
Returns true if both objects are not null and are both Arrays or Collections.
|
Difference |
compare(Object left,
Object right,
boolean onlyFirstDifference,
ReflectionComparator reflectionComparator)
Compares the given collections/arrays but ignoring the actual order of the elements.
|
protected ArrayList<Integer> |
createIndexList(int size) |
protected MatchingScoreCalculator |
createMatchingScoreCalculator()
Creates the calculator for determining the matching scores of the differences.
|
protected void |
fillAllDifferences(ArrayList<Object> leftList,
ArrayList<Object> rightList,
ReflectionComparator reflectionComparator,
UnorderedCollectionDifference difference)
Calculates the difference of all elements in the left list with all elements of the right list.
|
protected void |
fillBestMatchingIndexes(ArrayList<Object> leftList,
ArrayList<Object> rightList,
UnorderedCollectionDifference difference)
Calculates the indexes of the best matching differences for the given unordered collection difference.
|
protected boolean |
isEqual(ArrayList<Object> leftList,
ArrayList<Object> rightList,
int leftIndex,
ReflectionComparator reflectionComparator)
Recursively checks whether there is a sequence so that both collections have matching elements.
|
protected void |
removeMatchingIndexes(ArrayList<Integer> leftIndexes,
ArrayList<Integer> rightIndexes,
UnorderedCollectionDifference difference)
Removes all left and right indexes for which there is a match in the given difference object.
|
protected void |
setBestMatchingIndexes(ArrayList<Integer> leftIndexes,
ArrayList<Integer> rightIndexes,
UnorderedCollectionDifference difference)
Actual implementation of the best match finding algorithm.
|
public boolean canCompare(Object left, Object right)
canCompare in interface Comparatorleft - The left objectright - The right objectpublic Difference compare(Object left, Object right, boolean onlyFirstDifference, ReflectionComparator reflectionComparator)
compare in interface Comparatorleft - The left array/collection, not nullright - The right array/collection, not nullonlyFirstDifference - True if only the first difference should be returnedreflectionComparator - The root comparator for inner comparisons, not nullprotected boolean isEqual(ArrayList<Object> leftList, ArrayList<Object> rightList, int leftIndex, ReflectionComparator reflectionComparator)
leftList - The left list, not nullrightList - The right list, not nullleftIndex - The current index in the left collectionreflectionComparator - reflectionComparator The comparator for the element comparisons, not nullprotected void fillAllDifferences(ArrayList<Object> leftList, ArrayList<Object> rightList, ReflectionComparator reflectionComparator, UnorderedCollectionDifference difference)
leftList - The left list, not nullrightList - The right list, not nullreflectionComparator - The comparator for element comparisons, not nulldifference - The root difference to which all differences will be added, not nullprotected void fillBestMatchingIndexes(ArrayList<Object> leftList, ArrayList<Object> rightList, UnorderedCollectionDifference difference)
leftList - The left list, not nullrightList - The right list, not nulldifference - The difference to which all indexes will be added, not nullprotected void setBestMatchingIndexes(ArrayList<Integer> leftIndexes, ArrayList<Integer> rightIndexes, UnorderedCollectionDifference difference)
leftIndexes - The current remaining indexes in the left collection, not nullrightIndexes - The current remaining indexes in the right collection, not nulldifference - The difference to which all indexes will be added, not nullprotected void removeMatchingIndexes(ArrayList<Integer> leftIndexes, ArrayList<Integer> rightIndexes, UnorderedCollectionDifference difference)
leftIndexes - The indexes, not nullrightIndexes - The indexes, not nulldifference - The collection difference, not nullprotected ArrayList<Integer> createIndexList(int size)
size - The nr of elementsprotected MatchingScoreCalculator createMatchingScoreCalculator()
Copyright © 2016. All Rights Reserved.