Package org.apache.hc.core5.util
Class Args
java.lang.Object
org.apache.hc.core5.util.Args
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Args()
Private constructor so that no instances can be created. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
static void
static long
checkContentLength
(EntityDetails entityDetails) Deprecated.static int
checkRange
(int value, int lowInclusive, int highInclusive, String message) static long
checkRange
(long value, long lowInclusive, long highInclusive, String message) static <T extends CharSequence>
TcontainsNoBlanks
(T argument, String name) private static IllegalArgumentException
illegalArgumentException
(String format, Object... args) private static IllegalArgumentException
static boolean
Checks if an Object is empty or null.static <T extends CharSequence>
Tstatic <T extends CharSequence>
Tstatic int
notNegative
(int n, String name) static long
notNegative
(long n, String name) static <T> T
Validate that the specified argument is notnull
; otherwise throwing an exception with the specified message.private static NullPointerException
NullPointerException
(String name) static int
static long
static <T extends TimeValue>
T
-
Constructor Details
-
Args
private Args()Private constructor so that no instances can be created. This class contains only static utility methods.
-
-
Method Details
-
check
-
check
-
check
-
checkContentLength
Deprecated. -
checkRange
-
checkRange
-
containsNoBlanks
-
illegalArgumentException
-
illegalArgumentExceptionNotEmpty
-
NullPointerException
-
notBlank
-
notEmpty
-
notEmpty
-
notEmpty
-
notNegative
-
notNegative
-
notNull
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 checkname
- theString
exception message if invalid, not null- Returns:
- the validated object (never
null
for method chaining) - Throws:
NullPointerException
- if the object isnull
-
isEmpty
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
- theObject
to test, may benull
- Returns:
true
if the object has a supported type and is empty or null,false
otherwise- Since:
- 5.1
-
positive
-
positive
-
positive
-
checkRange(long, long, long, String)
.