Class ArgUtils

java.lang.Object
org.apache.juneau.common.internal.ArgUtils

public class ArgUtils extends Object
Method argument utility methods.
  • Constructor Details

  • Method Details

    • assertArgNotNull

      public static final <T> T assertArgNotNull(String name, T o) throws IllegalArgumentException
      Throws an IllegalArgumentException if the specified argument is null.
      Example:

      import static org.apache.juneau.internal.ArgUtils.*; public String setFoo(String foo) { assertArgNotNull("foo", foo); ... }

      Type Parameters:
      T - The argument data type.
      Parameters:
      name - The argument name.
      o - The object to check.
      Returns:
      The same argument.
      Throws:
      IllegalArgumentException - Constructed exception.
    • assertArg

      public static final void assertArg(boolean expression, String msg, Object... args) throws IllegalArgumentException
      Throws an IllegalArgumentException if the specified expression is false.
      Example:

      import static org.apache.juneau.internal.ArgUtils.*; public String setFoo(List<String> foo) { assertArg(foo != null && ! foo.isEmpty(), "'foo' cannot be null or empty."); ... }

      Parameters:
      expression - The boolean expression to check.
      msg - The exception message.
      args - The exception message args.
      Throws:
      IllegalArgumentException - Constructed exception.
    • assertClassArrayArgIsType

      public static final <E> Class<E>[] assertClassArrayArgIsType(String name, Class<E> type, Class<?>[] value) throws IllegalArgumentException
      Throws an IllegalArgumentException if the specified value doesn't have all subclasses of the specified type.
      Type Parameters:
      E - The element type.
      Parameters:
      name - The argument name.
      type - The expected parent class.
      value - The array value being checked.
      Returns:
      The value cast to the specified array type.
      Throws:
      IllegalArgumentException - Constructed exception.