org.test4j.hamcrest.matcher.property.reflection
类 MatchingScoreCalculator

java.lang.Object
  继承者 org.test4j.hamcrest.matcher.property.reflection.MatchingScoreCalculator

public class MatchingScoreCalculator
extends Object

A utility class to be able to calculate a score of how well 2 elements match. This enables us to find the best matching differences out of all element differences in an unordered collection difference.


嵌套类摘要
protected  class MatchingScoreCalculator.MatchingScoreVisitor
          The visitor for visiting the difference tree.
 
字段摘要
protected  Map<Difference,Integer> cachedMatchingScores
          Cache for matching scores
protected  MatchingScoreCalculator.MatchingScoreVisitor matchingScoreVisitor
          The visitor for visiting the difference tree
 
构造方法摘要
MatchingScoreCalculator()
           
 
方法摘要
 int calculateMatchingScore(Difference difference)
          Gets the matching score for the given difference.
protected  int getMatchingScore(CollectionDifference collectionDifference)
          Gets the matching score for a collection difference.
protected  int getMatchingScore(Difference difference)
          Gets the matching score for a simple difference.
protected  int getMatchingScore(MapDifference mapDifference)
          Gets the matching score for a map difference.
protected  int getMatchingScore(ObjectDifference objectDifference)
          Gets the matching score for an object difference.
protected  int getMatchingScore(UnorderedCollectionDifference unorderedCollectionDifference)
          Gets the matching score for an unordered collection difference.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

matchingScoreVisitor

protected MatchingScoreCalculator.MatchingScoreVisitor matchingScoreVisitor
The visitor for visiting the difference tree


cachedMatchingScores

protected Map<Difference,Integer> cachedMatchingScores
Cache for matching scores

构造方法详细信息

MatchingScoreCalculator

public MatchingScoreCalculator()
方法详细信息

calculateMatchingScore

public int calculateMatchingScore(Difference difference)
Gets the matching score for the given difference.

参数:
difference - The difference
返回:
The score

getMatchingScore

protected int getMatchingScore(Difference difference)
Gets the matching score for a simple difference. This will return 0 in case both objects are of the same type. If both objects are of a different type, they are less likely to be a best match, so 5 is returned.

参数:
difference - The difference, not null
返回:
The score

getMatchingScore

protected int getMatchingScore(ObjectDifference objectDifference)
Gets the matching score for an object difference. Returns the nr of field differences.

参数:
objectDifference - The difference, not null
返回:
The score

getMatchingScore

protected int getMatchingScore(MapDifference mapDifference)
Gets the matching score for a map difference. Returns the nr of value differences.

参数:
mapDifference - The difference, not null
返回:
The score

getMatchingScore

protected int getMatchingScore(CollectionDifference collectionDifference)
Gets the matching score for a collection difference. Returns the nr of element differences.

参数:
collectionDifference - The difference, not null
返回:
The score

getMatchingScore

protected int getMatchingScore(UnorderedCollectionDifference unorderedCollectionDifference)
Gets the matching score for an unordered collection difference. Returns the sum of the matching scores of the best matches.

参数:
unorderedCollectionDifference - The difference, not null
返回:
The score


Copyright © 2013. All rights reserved.