Package io.smallrye.mutiny.helpers
Class ParameterValidation
- java.lang.Object
-
- io.smallrye.mutiny.helpers.ParameterValidation
-
public class ParameterValidation extends java.lang.ObjectA class to validate method parameters. these methods throwIllegalArgumentExceptionis the validation fails.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMAPPER_RETURNED_NULLstatic java.lang.StringSUPPLIER_PRODUCED_NULL
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]doesNotContainNull(T[] array, java.lang.String name)Ensures that the given array does not contain anullvalue.static <T extends java.lang.Iterable<?>>
TdoesNotContainNull(T iterable, java.lang.String name)Ensures that the given iterable does not contain anullvalue.static <T> TnonNull(T instance, java.lang.String name)Validates that the giveninstanceis notnull.static <T> TnonNullNpe(T instance, java.lang.String name)Validates that the giveninstanceis notnull.static intpositive(int amount, java.lang.String name)Validates that the passed amount is strictly positive.static longpositive(long amount, java.lang.String name)Validates that the passed amount is strictly positive.static intpositiveOrZero(int amount, java.lang.String name)Validates that the passed amount is positive (including 0).static longpositiveOrZero(long amount, java.lang.String name)Validates that the passed amount is positive (including 0).static <T extends java.util.Collection<?>>
Tsize(T instance, int expectedSize, java.lang.String name)Validates that the given collectioninstancehas size matching theexpectedSizestatic java.time.Durationvalidate(java.time.Duration duration, java.lang.String name)Validates that the passed duration is notnulland strictly positive.
-
-
-
Field Detail
-
SUPPLIER_PRODUCED_NULL
public static final java.lang.String SUPPLIER_PRODUCED_NULL
- See Also:
- Constant Field Values
-
MAPPER_RETURNED_NULL
public static final java.lang.String MAPPER_RETURNED_NULL
- See Also:
- Constant Field Values
-
-
Method Detail
-
validate
public static java.time.Duration validate(java.time.Duration duration, java.lang.String name)Validates that the passed duration is notnulland strictly positive.- Parameters:
duration- the durationname- the name of the parameter, must not benull- Returns:
- the duration is the validation passes.
-
nonNull
public static <T> T nonNull(T instance, java.lang.String name)Validates that the giveninstanceis notnull.- Type Parameters:
T- the type of the instance- Parameters:
instance- the instancename- the name of the parameter, must not benull- Returns:
- the instance if the validation passes
-
nonNullNpe
public static <T> T nonNullNpe(T instance, java.lang.String name)Validates that the giveninstanceis notnull. UnlikenonNull(Object, String), this method throw aNullPointerException. It's generally used to be compliant with the Reactive Streams specification expectingNullPointerException.- Type Parameters:
T- the type of the instance- Parameters:
instance- the instancename- the name of the parameter, must not benull- Returns:
- the instance if the validation passes
-
positive
public static long positive(long amount, java.lang.String name)Validates that the passed amount is strictly positive.- Parameters:
amount- the amount to be checkedname- the name of the parameter, must not benull- Returns:
- the amount is the validation passes.
-
positive
public static int positive(int amount, java.lang.String name)Validates that the passed amount is strictly positive.- Parameters:
amount- the amount to be checkedname- the name of the parameter, must not benull- Returns:
- the amount is the validation passes.
-
positiveOrZero
public static int positiveOrZero(int amount, java.lang.String name)Validates that the passed amount is positive (including 0).- Parameters:
amount- the amount to be checkedname- the name of the parameter, must not benull- Returns:
- the amount is the validation passes.
-
positiveOrZero
public static long positiveOrZero(long amount, java.lang.String name)Validates that the passed amount is positive (including 0).- Parameters:
amount- the amount to be checkedname- the name of the parameter, must not benull- Returns:
- the amount is the validation passes.
-
doesNotContainNull
public static <T extends java.lang.Iterable<?>> T doesNotContainNull(T iterable, java.lang.String name)Ensures that the given iterable does not contain anullvalue.- Type Parameters:
T- the type of the instance- Parameters:
iterable- the iterablename- the name of the parameter, must not benull- Returns:
- the instance if the validation passes
-
doesNotContainNull
public static <T> T[] doesNotContainNull(T[] array, java.lang.String name)Ensures that the given array does not contain anullvalue.- Type Parameters:
T- the type of the item contained in the array- Parameters:
array- the arrayname- the name of the parameter, must not benull- Returns:
- the instance if the validation passes
-
size
public static <T extends java.util.Collection<?>> T size(T instance, int expectedSize, java.lang.String name)Validates that the given collectioninstancehas size matching theexpectedSize- Type Parameters:
T- the type of the instance- Parameters:
instance- the instanceexpectedSize- the expected sizename- the name of the parameter, must not benull- Returns:
- the instance if the validation passes
-
-