Package org.apache.hc.core5.util
Class Args
java.lang.Object
org.apache.hc.core5.util.Args
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateArgs()Private constructor so that no instances can be created. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidstatic voidstatic longcheckContentLength(EntityDetails entityDetails) Deprecated.static intcheckRange(int value, int lowInclusive, int highInclusive, String message) static longcheckRange(long value, long lowInclusive, long highInclusive, String message) static <T extends CharSequence>
TcontainsNoBlanks(T argument, String name) private static IllegalArgumentExceptionillegalArgumentException(String format, Object... args) private static IllegalArgumentExceptionstatic booleanChecks if an Object is empty or null.static <T extends CharSequence>
Tstatic <T extends CharSequence>
Tstatic intnotNegative(int n, String name) static longnotNegative(long n, String name) static <T> TValidate that the specified argument is notnull; otherwise throwing an exception with the specified message.private static NullPointerExceptionNullPointerException(String name) static intstatic longstatic <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- theStringexception message if invalid, not null- Returns:
- the validated object (never
nullfor 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- theObjectto test, may benull- Returns:
trueif the object has a supported type and is empty or null,falseotherwise- Since:
- 5.1
-
positive
-
positive
-
positive
-
checkRange(long, long, long, String).