Class ArgumentUtils

java.lang.Object
io.micronaut.core.util.ArgumentUtils

public class ArgumentUtils extends Object
Utility methods for checking method argument values.
Since:
1.0
Author:
Graeme Rocher
  • Constructor Details

    • ArgumentUtils

      public ArgumentUtils()
  • Method Details

    • requirePositive

      @NonNull public static @NonNull Number requirePositive(String name, Number value)
      Adds a check that the given number is positive.
      Parameters:
      name - The name of the argument
      value - The value
      Returns:
      The value
      Throws:
      IllegalArgumentException - if the argument is not positive
    • requireNonNull

      public static <T> T requireNonNull(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 argument
      value - The value
      Returns:
      The value
      Throws:
      NullPointerException - if the argument is null
    • requirePositive

      public static int requirePositive(String name, int value)
      Adds a check that the given number is positive.
      Parameters:
      name - The name of the argument
      value - The value
      Returns:
      The value
      Throws:
      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(String name, T value)
      Perform a check on an argument.
      Type Parameters:
      T - The value type
      Parameters:
      name - The name of the argument
      value - 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 instance
      arguments - The arguments
      values - The values