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
Nested ClassesModifier and TypeClassDescriptionstatic classAllows producing error messages.static interfaceFunctional interface the check a condition. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ArgumentUtils.ArgumentCheckcheck(ArgumentUtils.Check check) Perform a check on an argument.static <T> ArgumentUtils.ArgumentCheckPerform a check on an argument.static <T> TrequireNonNull(String name, T value) Adds a check that the given number is not null.static intrequirePositive(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 voidvalidateArguments(@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
-