Top Constructors Methods
org.apache.hc.core5.util

public Class Args

extends Object
Class Inheritance
Imports
java.lang.reflect.Array, java.util.Collection, .Map, .Objects, org.apache.hc.core5.http.EntityDetails

Constructor Summary

AccessConstructor and Description
private
Args()

Private constructor so that no instances can be created.

Method Summary

Modifier and TypeMethod and Description
public static void
check(final boolean expression, final String message)

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

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

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

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

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

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

private static IllegalArgumentException
public static boolean

Returns:

true if the object has a supported type and is empty or null, false otherwise
isEmpty
(final Object
the Object to test, may be null
object
)

Checks if an Object is empty or null.

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

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

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

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

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

public static long
notNegative(final long n, final String name)

public static <
the object type
T
>
T

Returns:

the validated object (never null for method chaining)
notNull
(final T
the object to check
argument
,
final String
the String exception message if invalid, not null
name
)

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

private static NullPointerException
public static int
positive(final int n, final String name)

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

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Argsback to summary
private Args()

Private constructor so that no instances can be created. This class contains only static utility methods.

Method Detail

checkback to summary
public static void check(final boolean expression, final String message)
checkback to summary
public static void check(final boolean expression, final String message, final Object... args)
checkback to summary
public static void check(final boolean expression, final String message, final Object arg)
checkContentLengthback to summary
public static long checkContentLength(final EntityDetails entityDetails)
Annotations
@Deprecated
checkRangeback to summary
public static int checkRange(final int value, final int lowInclusive, final int highInclusive, final String message)
checkRangeback to summary
public static long checkRange(final long value, final long lowInclusive, final long highInclusive, final String message)
containsNoBlanksback to summary
public static <T extends CharSequence> T containsNoBlanks(final T argument, final String name)
illegalArgumentExceptionback to summary
private static IllegalArgumentException illegalArgumentException(final String format, final Object... args)
illegalArgumentExceptionNotEmptyback to summary
private static IllegalArgumentException illegalArgumentExceptionNotEmpty(final String name)
isEmptyback to summary
public static boolean isEmpty(final 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:Object

the Object to test, may be null

Returns:boolean

true if the object has a supported type and is empty or null, false otherwise

Since
5.1
notBlankback to summary
public static <T extends CharSequence> T notBlank(final T argument, final String name)
notEmptyback to summary
public static <T extends CharSequence> T notEmpty(final T argument, final String name)
notEmptyback to summary
public static <E, T extends Collection<E>> T notEmpty(final T argument, final String name)
notEmptyback to summary
public static <T> T notEmpty(final T argument, final String name)
notNegativeback to summary
public static int notNegative(final int n, final String name)
notNegativeback to summary
public static long notNegative(final long n, final String name)
notNullback to summary
public static <T> T notNull(final T argument, final 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");
Parameters
<T>
the object type
argument:T

the object to check

name:String

the String exception message if invalid, not null

Returns:T

the validated object (never null for method chaining)

Exceptions
NullPointerException:
if the object is null
NullPointerExceptionback to summary
private static NullPointerException NullPointerException(final String name)
positiveback to summary
public static int positive(final int n, final String name)
positiveback to summary
public static long positive(final long n, final String name)
positiveback to summary
public static <T extends TimeValue> T positive(final T timeValue, final String name)