Package org.dbunit.dataset.datatype
Class NumberTolerantDataType
java.lang.Object
org.dbunit.dataset.datatype.DataType
org.dbunit.dataset.datatype.AbstractDataType
org.dbunit.dataset.datatype.NumberDataType
org.dbunit.dataset.datatype.NumberTolerantDataType
Extended version of the
NumberDataType. Extends the
AbstractDataType.compare(Object, Object) method in order to respect precision
tolerance. This is comparable to the JUnit method
assert(double val1, double val2, double toleratedDelta).- Since:
- 2.3.0
- Version:
- $Revision$ $Date$
- Author:
- gommma, Last changed by: $Author$
-
Field Summary
Fields inherited from class org.dbunit.dataset.datatype.DataType
BIGINT, BIGINT_AUX_LONG, BINARY, BIT, BLOB, BOOLEAN, CHAR, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER, LONGNVARCHAR, LONGVARBINARY, LONGVARCHAR, NCHAR, NUMERIC, NVARCHAR, REAL, RELATIVE_DATE_TIME_PARSER, SMALLINT, TIME, TIMESTAMP, TINYINT, UNKNOWN, VARBINARY, VARCHAR -
Method Summary
Modifier and TypeMethodDescriptionprotected intcompareNonNulls(Object value1cast, Object value2cast) The only method overwritten from the base implementation to compare numbers allowing a toleranceReturns the tolerated delta used for the comparison.static final booleanisZero(BigDecimal value) Checks if the given value is zero.Methods inherited from class org.dbunit.dataset.datatype.NumberDataType
getSqlValue, setSqlValue, typeCastMethods inherited from class org.dbunit.dataset.datatype.AbstractDataType
areObjectsEqual, compare, getSqlType, getTypeClass, isDateTime, isNumber, loadClass, loadClass, toStringMethods inherited from class org.dbunit.dataset.datatype.DataType
asString, forObject, forSqlType, forSqlTypeName, getSqlTypeName, isExtendedSyntax
-
Method Details
-
getToleratedDelta
Returns the tolerated delta used for the comparison.- Returns:
- the tolerated delta used for the comparison.
-
compareNonNulls
The only method overwritten from the base implementation to compare numbers allowing a tolerance- Overrides:
compareNonNullsin classAbstractDataType- Parameters:
value1cast- First value resulting from theDataType.typeCast(Object)method callvalue2cast- Second value resulting from theDataType.typeCast(Object)method call- Returns:
- The result of the
Comparable.compareTo(Object)invocation. - Throws:
TypeCastException- if either value cannot be cast to aComparable.- See Also:
-
isZero
Checks if the given value is zero.- Parameters:
value- the value to check.- Returns:
trueif and only if the given value is zero.
-