Package org.kie.soup.commons.validation
Class PortablePreconditions
- java.lang.Object
-
- org.kie.soup.commons.validation.PortablePreconditions
-
- Direct Known Subclasses:
Preconditions
public class PortablePreconditions extends Object
Helper class for parameters validation, such as not null arguments.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPortablePreconditions()Should not be instantiated
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckCondition(String name, boolean condition)Assert that this parameter is marked as valid by the condition passed as parameter.static <T> voidcheckEachParameterNotNull(String name, T... parameters)Assert that this parameter is not null, as also each item of the array is not null.static <T> voidcheckGreaterOrEqualTo(String name, Comparable<T> parameter, T nonNullValue)Assert that this parameter is not null and greater or equal to the nonNullValue.static <T> voidcheckGreaterThan(String name, Comparable<T> parameter, T nonNullValue)Assert that this parameter is not null and greater than the nonNullValue.static StringcheckNotEmpty(String name, String parameter)Assert that this parameter is not empty.static voidcheckNotEmpty(String name, Map<?,?> parameter)Assert that this parameter is not empty.static <T extends Collection<?>>
TcheckNotEmpty(String name, T parameter)Assert that this parameter is not empty.static <T> T[]checkNotEmpty(String name, T[] parameter)Assert that this parameter is not empty.static <T> TcheckNotNull(String name, T parameter)Assert that this parameter is not null.static voidcheckNullMandatory(String name, Object parameter)Assert that this parameter is null.
-
-
-
Method Detail
-
checkCondition
public static void checkCondition(String name, boolean condition)
Assert that this parameter is marked as valid by the condition passed as parameter.- Parameters:
name- of parametercondition- itself
-
checkEachParameterNotNull
public static <T> void checkEachParameterNotNull(String name, T... parameters)
Assert that this parameter is not null, as also each item of the array is not null.- Type Parameters:
T- parameter type- Parameters:
name- of parameterparameters- itself
-
checkNotEmpty
public static <T extends Collection<?>> T checkNotEmpty(String name, T parameter)
Assert that this parameter is not empty. It will test for null and also the size of this array.- Parameters:
name- of parameterparameter- itself
-
checkNotEmpty
public static void checkNotEmpty(String name, Map<?,?> parameter)
Assert that this parameter is not empty. It will test for null and also the size of this array.- Parameters:
name- of parameterparameter- itself
-
checkNotEmpty
public static String checkNotEmpty(String name, String parameter)
Assert that this parameter is not empty. It trims the parameter to see if have any valid data on that.- Parameters:
name- of parameterparameter- itself
-
checkNotEmpty
public static <T> T[] checkNotEmpty(String name, T[] parameter)
Assert that this parameter is not empty. It will test for null and also the size of this array.- Type Parameters:
T- type of the array- Parameters:
name- of parameterparameter- itself
-
checkNotNull
public static <T> T checkNotNull(String name, T parameter)
Assert that this parameter is not null.- Parameters:
name- of parameterparameter- itself
-
checkNullMandatory
public static void checkNullMandatory(String name, Object parameter)
Assert that this parameter is null.- Parameters:
name- of parameterparameter- itself
-
checkGreaterThan
public static <T> void checkGreaterThan(String name, Comparable<T> parameter, T nonNullValue)
Assert that this parameter is not null and greater than the nonNullValue.- Parameters:
name- of the parameter.parameter- the parameter value.nonNullValue- a non null value for executing the comparison.
-
checkGreaterOrEqualTo
public static <T> void checkGreaterOrEqualTo(String name, Comparable<T> parameter, T nonNullValue)
Assert that this parameter is not null and greater or equal to the nonNullValue.- Parameters:
name- of the parameter.parameter- the parameter value.nonNullValue- a non null value for executing the comparison.
-
-