Package io.micronaut.core.util
Class ArgumentUtils
- java.lang.Object
-
- io.micronaut.core.util.ArgumentUtils
-
public class ArgumentUtils extends java.lang.ObjectUtility methods for checking method argument values.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classArgumentUtils.ArgumentCheck<T>Allows producing error messages.static interfaceArgumentUtils.CheckFunctional interface the check a condition.
-
Constructor Summary
Constructors Constructor Description ArgumentUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ArgumentUtils.ArgumentCheckcheck(ArgumentUtils.Check check)Perform a check on an argument.static <T> ArgumentUtils.ArgumentCheckcheck(java.lang.String name, T value)Perform a check on an argument.static <T> TrequireNonNull(java.lang.String name, T value)Adds a check that the given number is not null.static intrequirePositive(java.lang.String name, int value)Adds a check that the given number is positive.static java.lang.NumberrequirePositive(java.lang.String name, java.lang.Number value)Adds a check that the given number is positive.static voidvalidateArguments(Described described, Argument<?>[] arguments, java.lang.Object[] values)Validates the given values are appropriate for the given arguments.
-
-
-
Method Detail
-
requirePositive
@NonNull public static java.lang.Number requirePositive(java.lang.String name, java.lang.Number value)
Adds a check that the given number is positive.- Parameters:
name- The name of the argumentvalue- The value- Returns:
- The value
- Throws:
java.lang.IllegalArgumentException- if the argument is not positive
-
requireNonNull
public static <T> T requireNonNull(java.lang.String name, T value)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:
java.lang.NullPointerException- if the argument is null
-
requirePositive
public static int requirePositive(java.lang.String name, int value)Adds a check that the given number is positive.- Parameters:
name- The name of the argumentvalue- The value- Returns:
- The value
- Throws:
java.lang.IllegalArgumentException- if the argument is not positive
-
check
public static ArgumentUtils.ArgumentCheck check(ArgumentUtils.Check check)
Perform a check on an argument.- Parameters:
check- The check- Returns:
- The
ArgumentUtils.ArgumentCheck
-
check
public static <T> ArgumentUtils.ArgumentCheck check(java.lang.String name, T value)
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 Described described, @NonNull Argument<?>[] arguments, @NonNull java.lang.Object[] values)
Validates the given values are appropriate for the given arguments.- Parameters:
described- The described instancearguments- The argumentsvalues- The values
-
-