Package org.eclipse.keyple.core.util
Class Assert
- java.lang.Object
-
- org.eclipse.keyple.core.util.Assert
-
public final class Assert extends java.lang.Object
Exposes 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 Assert
getInstance()
Gets the unique instance.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.Assert
isEqual(java.lang.Integer number, int value, java.lang.String name)
Assert that an integer is equal to value.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.Assert
isTrue(java.lang.Boolean condition, java.lang.String name)
Assert that a condition is true.Assert
notEmpty(byte[] obj, java.lang.String name)
Assert that a byte array is not null and not empty.Assert
notEmpty(java.lang.String obj, java.lang.String name)
Assert that the input string is not null and not empty.Assert
notEmpty(java.util.Collection<? extends java.lang.Object> obj, java.lang.String name)
Assert that a collection of objects is not null and not empty.Assert
notNull(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<? extends java.lang.Object> 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
-
-