Package io.micronaut.core.util
Class ArgumentUtils
java.lang.Object
io.micronaut.core.util.ArgumentUtils
Utility methods for checking method argument values.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Allows producing error messages.static interface
Functional interface the check a condition. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ArgumentUtils.ArgumentCheck
check
(ArgumentUtils.Check check) Perform a check on an argument.static <T> ArgumentUtils.ArgumentCheck
Perform a check on an argument.static <T> T
requireNonNull
(String name, T value) Adds a check that the given number is not null.static int
requirePositive
(String name, int value) Adds a check that the given number is positive.requirePositive
(String name, Number value) Adds a check that the given number is positive.static void
validateArguments
(@NonNull Described described, @NonNull Argument<?>[] arguments, @NonNull Object[] values) Validates the given values are appropriate for the given arguments.
-
Constructor Details
-
ArgumentUtils
public ArgumentUtils()
-
-
Method Details
-
requirePositive
Adds a check that the given number is positive.- Parameters:
name
- The name of the argumentvalue
- The value- Returns:
- The value
- Throws:
IllegalArgumentException
- if the argument is not positive
-
requireNonNull
Adds a check that the given number is not null.- Type Parameters:
T
- The generic type- Parameters:
name
- The name of the argumentvalue
- The value- Returns:
- The value
- Throws:
NullPointerException
- if the argument is null
-
requirePositive
Adds a check that the given number is positive.- Parameters:
name
- The name of the argumentvalue
- The value- Returns:
- The value
- Throws:
IllegalArgumentException
- if the argument is not positive
-
check
Perform a check on an argument.- Parameters:
check
- The check- Returns:
- The
ArgumentUtils.ArgumentCheck
-
check
Perform a check on an argument.- Type Parameters:
T
- The value type- Parameters:
name
- The name of the argumentvalue
- The value of the argument- Returns:
- The
ArgumentUtils.ArgumentCheck
-
validateArguments
public static void validateArguments(@NonNull @NonNull Described described, @NonNull @NonNull Argument<?>[] arguments, @NonNull @NonNull Object[] values) Validates the given values are appropriate for the given arguments.- Parameters:
described
- The described instancearguments
- The argumentsvalues
- The values
-