public class ArgumentUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ArgumentUtils.ArgumentCheck<T>
Allows producing error messages.
|
static interface |
ArgumentUtils.Check
Functional interface the check a condition.
|
Constructor and Description |
---|
ArgumentUtils() |
Modifier and Type | Method and Description |
---|---|
static ArgumentUtils.ArgumentCheck |
check(ArgumentUtils.Check check)
Perform a check on an argument.
|
static <T> ArgumentUtils.ArgumentCheck |
check(String name,
T value)
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.
|
static Number |
requirePositive(String name,
Number value)
Adds a check that the given number is positive.
|
static void |
validateArguments(Described described,
Argument<?>[] arguments,
Object[] values)
Validates the given values are appropriate for the given arguments.
|
@NonNull public static Number requirePositive(String name, Number value)
name
- The name of the argumentvalue
- The valueIllegalArgumentException
- if the argument is not positivepublic static <T> T requireNonNull(String name, T value)
T
- The generic typename
- The name of the argumentvalue
- The valueNullPointerException
- if the argument is nullpublic static int requirePositive(String name, int value)
name
- The name of the argumentvalue
- The valueIllegalArgumentException
- if the argument is not positivepublic static ArgumentUtils.ArgumentCheck check(ArgumentUtils.Check check)
check
- The checkArgumentUtils.ArgumentCheck
public static <T> ArgumentUtils.ArgumentCheck check(String name, T value)
T
- The value typename
- The name of the argumentvalue
- The value of the argumentArgumentUtils.ArgumentCheck
public static void validateArguments(@NonNull Described described, @NonNull Argument<?>[] arguments, @NonNull Object[] values)
described
- The described instancearguments
- The argumentsvalues
- The values