Class Args

java.lang.Object
org.apache.hc.core5.util.Args

public class Args extends Object
  • Constructor Details

    • Args

      private Args()
      Private constructor so that no instances can be created. This class contains only static utility methods.
  • Method Details

    • check

      public static void check(boolean expression, String message)
    • check

      public static void check(boolean expression, String message, Object... args)
    • check

      public static void check(boolean expression, String message, Object arg)
    • checkContentLength

      @Deprecated public static long checkContentLength(EntityDetails entityDetails)
    • checkRange

      public static int checkRange(int value, int lowInclusive, int highInclusive, String message)
    • checkRange

      public static long checkRange(long value, long lowInclusive, long highInclusive, String message)
    • containsNoBlanks

      public static <T extends CharSequence> T containsNoBlanks(T argument, String name)
    • illegalArgumentException

      private static IllegalArgumentException illegalArgumentException(String format, Object... args)
    • illegalArgumentExceptionNotEmpty

      private static IllegalArgumentException illegalArgumentExceptionNotEmpty(String name)
    • NullPointerException

      private static NullPointerException NullPointerException(String name)
    • notBlank

      public static <T extends CharSequence> T notBlank(T argument, String name)
    • notEmpty

      public static <T extends CharSequence> T notEmpty(T argument, String name)
    • notEmpty

      public static <E, T extends Collection<E>> T notEmpty(T argument, String name)
    • notEmpty

      public static <T> T notEmpty(T argument, String name)
    • notNegative

      public static int notNegative(int n, String name)
    • notNegative

      public static long notNegative(long n, String name)
    • notNull

      public static <T> T notNull(T argument, String name)

      Validate that the specified argument is not null; otherwise throwing an exception with the specified message.

      Args.notNull(myObject, "The object must not be null");
      Type Parameters:
      T - the object type
      Parameters:
      argument - the object to check
      name - the String exception message if invalid, not null
      Returns:
      the validated object (never null for method chaining)
      Throws:
      NullPointerException - if the object is null
    • isEmpty

      public static boolean isEmpty(Object object)

      Checks if an Object is empty or null.

      The following types are supported:
      • CharSequence: Considered empty if its length is zero.
      • Array: Considered empty if its length is zero.
      • Collection: Considered empty if it has zero elements.
      • Map: Considered empty if it has zero key-value mappings.
       Args.isEmpty(null)             = true
       Args.isEmpty("")               = true
       Args.isEmpty("ab")             = false
       Args.isEmpty(new int[]{})      = true
       Args.isEmpty(new int[]{1,2,3}) = false
       Args.isEmpty(1234)             = false
       
      Parameters:
      object - the Object to test, may be null
      Returns:
      true if the object has a supported type and is empty or null, false otherwise
      Since:
      5.1
    • positive

      public static int positive(int n, String name)
    • positive

      public static long positive(long n, String name)
    • positive

      public static <T extends TimeValue> T positive(T timeValue, String name)