Package org.eclipse.keyple.core.util
Class Assert
java.lang.Object
org.eclipse.keyple.core.util.Assert
Exposes useful methods for testing method call parameters and raising a IllegalArgumentException
unchecked exception.
- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic Assert
Gets the unique instance.greaterOrEqual
(Integer number, int minValue, String name) Assert that an integer is not null and is greater than or equal to minValue.Assert that an integer is equal to value.isHexString
(String hex, String name) Assert that a string has a valid hexadecimal format.Assert that an integer is not null and is in the range minValue, maxValue.Assert that a condition is true.Assert that a byte array is not null and not empty.Assert that the input string is not null and not empty.notEmpty
(Collection<?> obj, String name) Assert that a collection of objects is not null and not empty.Assert that the input object is not null.
-
Method Details
-
getInstance
Gets the unique instance.- Returns:
- the instance
-
notNull
Assert that the input object is not null.- Parameters:
obj
- the object to checkname
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if object is null- Since:
- 2.0.0
-
notEmpty
Assert that the input string is not null and not empty.- Parameters:
obj
- the object to checkname
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if object is null or empty- Since:
- 2.0.0
-
notEmpty
Assert that a collection of objects is not null and not empty.- Parameters:
obj
- the object to checkname
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if object is null or empty- Since:
- 2.0.0
-
notEmpty
Assert that a byte array is not null and not empty.- Parameters:
obj
- the object to checkname
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if object is null or empty- Since:
- 2.0.0
-
isTrue
Assert that a condition is true.- Parameters:
condition
- the condition to checkname
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if condition is null or false- Since:
- 2.0.0
-
greaterOrEqual
Assert that an integer is not null and is greater than or equal to minValue.- Parameters:
number
- the number to checkminValue
- the min accepted valuename
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if number is null or has a value less than minValue.- Since:
- 2.0.0
-
isEqual
Assert that an integer is equal to value.- Parameters:
number
- the number to checkvalue
- the expected valuename
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if number is null or has a value less than minValue.- Since:
- 2.0.0
-
isInRange
Assert that an integer is not null and is in the range minValue, maxValue.- Parameters:
number
- the number to checkminValue
- the min accepted valuemaxValue
- the max accepted valuename
- the object name- Returns:
- the current instance
- Throws:
IllegalArgumentException
- if number is null or is out of range.- Since:
- 2.0.0
-
isHexString
Assert that a string has a valid hexadecimal format.- Parameters:
hex
- The string to check.name
- The object name.- Returns:
- The current instance.
- Throws:
IllegalArgumentException
- If the provided string is null, empty or has not a valid hexadecimal format.- Since:
- 2.1.0
-