Package org.eclipse.keyple.core.util
Class Assert
- java.lang.Object
-
- org.eclipse.keyple.core.util.Assert
-
public final class Assert extends java.lang.ObjectExposes useful methods for testing method call parameters and raising a IllegalArgumentException unchecked exception.- Since:
- 2.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AssertgetInstance()Gets the unique instance.AssertgreaterOrEqual(java.lang.Integer number, int minValue, java.lang.String name)Assert that an integer is not null and is greater than or equal to minValue.AssertisEqual(java.lang.Integer number, int value, java.lang.String name)Assert that an integer is equal to value.AssertisHexString(java.lang.String hex, java.lang.String name)Assert that a string has a valid hexadecimal format.AssertisInRange(java.lang.Integer number, int minValue, int maxValue, java.lang.String name)Assert that an integer is not null and is in the range minValue, maxValue.AssertisTrue(java.lang.Boolean condition, java.lang.String name)Assert that a condition is true.AssertnotEmpty(byte[] obj, java.lang.String name)Assert that a byte array is not null and not empty.AssertnotEmpty(java.lang.String obj, java.lang.String name)Assert that the input string is not null and not empty.AssertnotEmpty(java.util.Collection<?> obj, java.lang.String name)Assert that a collection of objects is not null and not empty.AssertnotNull(java.lang.Object obj, java.lang.String name)Assert that the input object is not null.
-
-
-
Method Detail
-
getInstance
public static Assert getInstance()
Gets the unique instance.- Returns:
- the instance
-
notNull
public Assert notNull(java.lang.Object obj, java.lang.String name)
Assert that the input object is not null.- Parameters:
obj- the object to checkname- the object name- Returns:
- the current instance
- Throws:
java.lang.IllegalArgumentException- if object is null- Since:
- 2.0.0
-
notEmpty
public Assert notEmpty(java.lang.String obj, java.lang.String name)
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:
java.lang.IllegalArgumentException- if object is null or empty- Since:
- 2.0.0
-
notEmpty
public Assert notEmpty(java.util.Collection<?> obj, java.lang.String name)
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:
java.lang.IllegalArgumentException- if object is null or empty- Since:
- 2.0.0
-
notEmpty
public Assert notEmpty(byte[] obj, java.lang.String name)
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:
java.lang.IllegalArgumentException- if object is null or empty- Since:
- 2.0.0
-
isTrue
public Assert isTrue(java.lang.Boolean condition, java.lang.String name)
Assert that a condition is true.- Parameters:
condition- the condition to checkname- the object name- Returns:
- the current instance
- Throws:
java.lang.IllegalArgumentException- if condition is null or false- Since:
- 2.0.0
-
greaterOrEqual
public Assert greaterOrEqual(java.lang.Integer number, int minValue, java.lang.String name)
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:
java.lang.IllegalArgumentException- if number is null or has a value less than minValue.- Since:
- 2.0.0
-
isEqual
public Assert isEqual(java.lang.Integer number, int value, java.lang.String name)
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:
java.lang.IllegalArgumentException- if number is null or has a value less than minValue.- Since:
- 2.0.0
-
isInRange
public Assert isInRange(java.lang.Integer number, int minValue, int maxValue, java.lang.String name)
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:
java.lang.IllegalArgumentException- if number is null or is out of range.- Since:
- 2.0.0
-
isHexString
public Assert isHexString(java.lang.String hex, java.lang.String name)
Assert that a string has a valid hexadecimal format.- Parameters:
hex- The string to check.name- The object name.- Returns:
- The current instance.
- Throws:
java.lang.IllegalArgumentException- If the provided string is null, empty or has not a valid hexadecimal format.- Since:
- 2.1.0
-
-