|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.oddjob.beancmpr.comparers.NumericComparer
public class NumericComparer
A Comparer
for numbers that supports tolerances and provides
the comparison as a difference between the numbers and as a percentage
change between numbers.
The change is considered as going from x to y. If x is 200 and y is 190, the delta is -10, and the percentage chnage is 5%.
Two numbers are only considered different if their delta is more the given tolerance or more. The tolerance may be specified as either a delta tolerance number that two numbers must differ more than, or a minimum percentage change that the two number must exceed.
The comparison is only unequal if the difference between the two numbers is greater than both tolerances. Both tolerances default to zero.
If either or both input number is null, the result of the compare is null.
Constructor Summary | |
---|---|
NumericComparer()
|
Method Summary | |
---|---|
NumericComparison |
compare(Number x,
Number y)
Compare two things. |
String |
getDeltaFormat()
|
double |
getDeltaTolerance()
|
String |
getPercentageFormat()
|
double |
getPercentageTolerance()
|
Class<Number> |
getType()
The type of the things. |
void |
setDeltaFormat(String deltaFormat)
|
void |
setDeltaTolerance(double deltaTolerance)
|
void |
setPercentageFormat(String percentageFormat)
|
void |
setPercentageTolerance(double percentageTolerance)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NumericComparer()
Method Detail |
---|
public NumericComparison compare(Number x, Number y)
Comparer
compare
in interface Comparer<Number>
x
- One thing.y
- The other thing.
public Class<Number> getType()
Comparer
Note that we would have liked the return type
to be Class<T>
but we could not then have had a
Comparer<Iterable<MatchableGroup>>
because it's not possible to
return a type of Class<Iterable<MatchableGroup>>
in Java.
If there is a solution to this then please let us know.
getType
in interface Comparer<Number>
public double getDeltaTolerance()
public void setDeltaTolerance(double deltaTolerance)
public double getPercentageTolerance()
public void setPercentageTolerance(double percentageTolerance)
public String getDeltaFormat()
public void setDeltaFormat(String deltaFormat)
public String getPercentageFormat()
public void setPercentageFormat(String percentageFormat)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |