Package com.tonic.analysis.similarity
Class SimilarityResult
- java.lang.Object
-
- com.tonic.analysis.similarity.SimilarityResult
-
- All Implemented Interfaces:
Comparable<SimilarityResult>
public class SimilarityResult extends Object implements Comparable<SimilarityResult>
The scored outcome of comparing two methods, ordered by descending overall score.
-
-
Constructor Summary
Constructors Constructor Description SimilarityResult(MethodSignature method1, MethodSignature method2, Map<SimilarityMetric,Double> scores, SimilarityMetric primaryMetric)Creates a result and derives the overall score from the primary metric, or a weighted average when the primary metric is COMBINED.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(SimilarityResult other)Map<SimilarityMetric,Double>getAllScores()MethodSignaturegetMethod1()MethodSignaturegetMethod2()doublegetOverallScore()SimilarityMetricgetPrimaryMetric()doublegetScore(SimilarityMetric metric)intgetScorePercent()StringgetSummary()booleanisHighlySimilar()booleanisPotentialDuplicate()StringtoString()
-
-
-
Constructor Detail
-
SimilarityResult
public SimilarityResult(MethodSignature method1, MethodSignature method2, Map<SimilarityMetric,Double> scores, SimilarityMetric primaryMetric)
Creates a result and derives the overall score from the primary metric, or a weighted average when the primary metric is COMBINED.- Parameters:
method1- the first compared methodmethod2- the second compared methodscores- the per-metric scores, copiedprimaryMetric- the metric that determines the overall score
-
-
Method Detail
-
getMethod1
public MethodSignature getMethod1()
- Returns:
- the method1
-
getMethod2
public MethodSignature getMethod2()
- Returns:
- the method2
-
getOverallScore
public double getOverallScore()
- Returns:
- the overall score
-
getScorePercent
public int getScorePercent()
- Returns:
- the overall score rounded to a 0-100 percentage
-
getPrimaryMetric
public SimilarityMetric getPrimaryMetric()
- Returns:
- the primary metric
-
getScore
public double getScore(SimilarityMetric metric)
- Parameters:
metric- the metric to read- Returns:
- the score for that metric, or 0.0 if absent
-
getAllScores
public Map<SimilarityMetric,Double> getAllScores()
- Returns:
- a copy of the per-metric scores
-
isPotentialDuplicate
public boolean isPotentialDuplicate()
- Returns:
- true if the overall score is at least 0.95
-
isHighlySimilar
public boolean isHighlySimilar()
- Returns:
- true if the overall score is at least 0.80
-
getSummary
public String getSummary()
- Returns:
- a short human-readable label of the similarity band with the percentage
-
compareTo
public int compareTo(SimilarityResult other)
- Specified by:
compareToin interfaceComparable<SimilarityResult>
-
-