| java.lang.Object org.isqlviewer.util.Assertions
Assertions | final public class Assertions (Code) | | General utilities class for common data validation patterns and assertions.
Some of these methods are variations on the themes in JUnit however the exceptions thrown herein are more appropriate
for runtime situations like
NullPointerException , and
IllegalArgumentException . Where as most
applications are not actively catching an AssertionFailedError which can fall through an Exception trap.
The NULL_XXX constants defined within this class also help facilitate the usage of Object versions of primitive
data-types, where normally primitives cannot be null, and typically a -1 or NaN would represent a null primitive.
These object instances assist with code-readability when dealing with those types of situations.
author: Mark A. Kobold version: 1.0 |
Field Summary | |
final public static Boolean | NULL_BOOLEAN User constant for defining an null primitive boolean value. | final public static Byte | NULL_BYTE User constant for defining an null primitive byte value. | final public static Character | NULL_CHARACTER User constant for defining an null primitive character value. | final public static Date | NULL_DATE User constant for defining an null date. | final public static Double | NULL_DOUBLE User constant for defining an null primitive double value. | final public static Float | NULL_FLOAT User constant for defining an null primitive float value. | final public static Integer | NULL_INTEGER User constant for defining an null primitive integer value. | final public static Long | NULL_LONG User constant for defining an null primitive long value. | final public static Short | NULL_SHORT User constant for defining an null primitive short value. |
Method Summary | |
public static void | assertEqual(String identifier, double expected, double actualValue) Asserts that the expected value is equal to the actual value. | public static void | assertEqual(double expected, double actualValue) Asserts that the expected value is equal to the actual value. | public static void | assertGreaterThanEqual(String identifier, double value, double minimumValue) Checks to ensure that the given value is greater than or equal to minimum required value. | public static void | assertGreaterThanEqual(double value, double minimumValue) Checks to ensure that the given value is greater than or equal to minimum required value. | public static void | assertLessThanEqual(String identifier, double value, double maximumValue) Checks to ensure that the given value is less than or equal to given maximum value. | public static void | assertLessThanEqual(double value, double maximumValue) Checks to ensure that the given value is less than or equal to given maximum value. | public static void | assertNotNull(String identifier, Object value) Check to make sure that given value by name is not null. | public static void | assertNotNull(Object value) Check to make sure that given value is not null. | public static void | assertNull(String identifier, Object value) Check to make sure that given value by name is null. | public static void | assertNull(Object value) Check to make sure that given value is null. | public static void | assertPositive(Number value) Checks to ensure that the value is not less than zero.
Utility method for ensuring that the given value is positive otherwise throw an exception. | public static void | assertPositive(String identifier, double value) Checks to ensure that the value is not less than zero. | public static void | assertPositive(String identifier, Number value) Checks to ensure that a Number value is not less than zero. | public static void | assertPositive(double value) Checks to ensure that the value is not less than zero.
Utility method for ensuring that the given value is positive otherwise throw an exception. | public static void | assertPositiveExcludeZero(double value) Checks to ensure that the value is not less than or equal zero. | public static void | assertPositiveExcludeZero(Number value) Checks to ensure that the value is not less than or equal zero. | public static void | assertPositiveExcludeZero(String identifier, double value) Checks to ensure that the value is not less than or equal zero. | public static void | assertPositiveExcludeZero(String identifier, Number value) Checks to ensure that the value is not less than or equal zero. |
NULL_BOOLEAN | final public static Boolean NULL_BOOLEAN(Code) | | User constant for defining an null primitive boolean value.
Assertions.NULL_BOOLEAN.booleanValue() == false
|
NULL_BYTE | final public static Byte NULL_BYTE(Code) | | User constant for defining an null primitive byte value.
(Assertions.NULL_BYTE.byteValue() == -1) == true
|
NULL_CHARACTER | final public static Character NULL_CHARACTER(Code) | | User constant for defining an null primitive character value.
(Assertions.NULL_CHARACTER.charValue() == 0) == true
|
NULL_DATE | final public static Date NULL_DATE(Code) | | User constant for defining an null date.
(Assertions.NULL_DATE.getTime() == 0) == true
Though this isn't a primitive type, it is effectively a wrapper for a long value,plus it is common data-type.
|
NULL_DOUBLE | final public static Double NULL_DOUBLE(Code) | | User constant for defining an null primitive double value.
Double.isNaN(Assertions.NULL_DOUBLE) == true
|
NULL_FLOAT | final public static Float NULL_FLOAT(Code) | | User constant for defining an null primitive float value.
Float.isNaN(Assertions.NULL_FLOAT) == true
|
NULL_INTEGER | final public static Integer NULL_INTEGER(Code) | | User constant for defining an null primitive integer value.
(Assertions.NULL_INTEGER.intValue() == -1) == true
|
NULL_LONG | final public static Long NULL_LONG(Code) | | User constant for defining an null primitive long value.
(Assertions.NULL_LONG.longValue() == -1) == true
|
NULL_SHORT | final public static Short NULL_SHORT(Code) | | User constant for defining an null primitive short value.
(Assertions.NULL_SHORT.shortValue() == -1) == true
|
assertEqual | public static void assertEqual(String identifier, double expected, double actualValue)(Code) | | Asserts that the expected value is equal to the actual value.
Parameters: string - identifier for this assertion; can be null. Parameters: expected - value of the actualValue variable. Parameters: actualValue - to verify against the expected value. throws: IllegalArgumentException - if the values are not equal. |
assertEqual | public static void assertEqual(double expected, double actualValue)(Code) | | Asserts that the expected value is equal to the actual value.
Parameters: expected - value of the actualValue variable. Parameters: actualValue - to verify against the expected value. throws: IllegalArgumentException - if the values are not equal. |
assertGreaterThanEqual | public static void assertGreaterThanEqual(String identifier, double value, double minimumValue)(Code) | | Checks to ensure that the given value is greater than or equal to minimum required value.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to assert that is less or equal to the maximum value. Parameters: minimumValue - the smallest value allowed. throws: IllegalArgumentException - if the value is greater than the maximum value. |
assertGreaterThanEqual | public static void assertGreaterThanEqual(double value, double minimumValue)(Code) | | Checks to ensure that the given value is greater than or equal to minimum required value.
Parameters: value - to assert that is less or equal to the maximum value. Parameters: minimumValue - the smallest value allowed. throws: IllegalArgumentException - if the value is greater than the maximum value. |
assertLessThanEqual | public static void assertLessThanEqual(String identifier, double value, double maximumValue)(Code) | | Checks to ensure that the given value is less than or equal to given maximum value.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to assert that is less or equal to the maximum value. Parameters: maximumValue - that the given value is allowed to be. throws: IllegalArgumentException - if the value is greater than the maximum value. |
assertLessThanEqual | public static void assertLessThanEqual(double value, double maximumValue)(Code) | | Checks to ensure that the given value is less than or equal to given maximum value.
Parameters: value - to assert that is less or equal to the maximum value. Parameters: maximumValue - that the given value is allowed to be. throws: IllegalArgumentException - if the value is greater than the maximum value. |
assertNotNull | public static void assertNotNull(String identifier, Object value)(Code) | | Check to make sure that given value by name is not null.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to check for null. throws: NullPointerException - if the given value is null. |
assertNotNull | public static void assertNotNull(Object value)(Code) | | Check to make sure that given value is not null.
Parameters: value - to check for null. throws: NullPointerException - if the given value is null. |
assertNull | public static void assertNull(String identifier, Object value)(Code) | | Check to make sure that given value by name is null.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to check for null. throws: IllegalArgumentException - if the given value is not null. |
assertNull | public static void assertNull(Object value)(Code) | | Check to make sure that given value is null.
Parameters: value - to check for null. throws: IllegalArgumentException - if the given value is not null. |
assertPositive | public static void assertPositive(Number value)(Code) | | Checks to ensure that the value is not less than zero.
Utility method for ensuring that the given value is positive otherwise throw an exception. This method version
assumes no logical identifier with the given argument.
Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than zero. throws: NullPointerException - if the given value is null. |
assertPositive | public static void assertPositive(String identifier, double value)(Code) | | Checks to ensure that the value is not less than zero.
Utility method for ensuring that the given value is positive otherwise throw an exception.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than zero. |
assertPositive | public static void assertPositive(String identifier, Number value)(Code) | | Checks to ensure that a Number value is not less than zero.
Utility method for ensuring that the given value is positive otherwise throw an exception.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than zero. throws: NullPointerException - if the given number value is null. |
assertPositive | public static void assertPositive(double value)(Code) | | Checks to ensure that the value is not less than zero.
Utility method for ensuring that the given value is positive otherwise throw an exception. This method version
assumes no logical identifier with the given argument.
Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than zero. |
assertPositiveExcludeZero | public static void assertPositiveExcludeZero(double value)(Code) | | Checks to ensure that the value is not less than or equal zero.
Utility method for ensuring that the given value is positive excluding zero, otherwise throw an exception.
Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than or equal zero. |
assertPositiveExcludeZero | public static void assertPositiveExcludeZero(Number value)(Code) | | Checks to ensure that the value is not less than or equal zero.
Utility method for ensuring that the given value is positive excluding zero, otherwise throw an exception.
Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than or equal zero. |
assertPositiveExcludeZero | public static void assertPositiveExcludeZero(String identifier, double value)(Code) | | Checks to ensure that the value is not less than or equal zero.
Utility method for ensuring that the given value is positive excluding zero, otherwise throw an exception.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than or equal zero. |
assertPositiveExcludeZero | public static void assertPositiveExcludeZero(String identifier, Number value)(Code) | | Checks to ensure that the value is not less than or equal zero.
Utility method for ensuring that the given value is positive excluding zero, otherwise throw an exception.
Parameters: identifier - a logical name that will accompany the exception if generated; can be null. Parameters: value - to check for positiveness. throws: IllegalArgumentException - if the given value is less than or equal zero. throws: NullPointerException - if the given number value is null. |
|
|