public class Args extends Object
Modifier and Type | Method and Description |
---|---|
static void |
check(boolean expression,
String message) |
static void |
check(boolean expression,
String message,
Object... args) |
static void |
check(boolean expression,
String message,
Object arg) |
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> |
containsNoBlanks(T argument,
String name) |
static boolean |
isEmpty(Object object)
Checks if an Object is empty or null.
|
static <T extends CharSequence> |
notBlank(T argument,
String name) |
static <E,T extends Collection<E>> |
notEmpty(T argument,
String name) |
static <T> T |
notEmpty(T argument,
String name) |
static <T extends CharSequence> |
notEmpty(T argument,
String name) |
static int |
notNegative(int n,
String name) |
static long |
notNegative(long n,
String name) |
static <T> T |
notNull(T argument,
String name)
Validate that the specified argument is not
null ;
otherwise throwing an exception with the specified message. |
static int |
positive(int n,
String name) |
static long |
positive(long n,
String name) |
static <T extends TimeValue> |
positive(T timeValue,
String name) |
public static void check(boolean expression, String message)
@Deprecated public static long checkContentLength(EntityDetails entityDetails)
checkRange(long, long, long, String)
.public static int checkRange(int value, int lowInclusive, int highInclusive, String message)
public static long checkRange(long value, long lowInclusive, long highInclusive, String message)
public static <T extends CharSequence> T containsNoBlanks(T argument, String name)
public static <T extends CharSequence> T notBlank(T argument, String name)
public static <T extends CharSequence> T notEmpty(T argument, String name)
public static <E,T extends Collection<E>> T notEmpty(T argument, String name)
public static <T> T notEmpty(T argument, String name)
public static int notNegative(int n, String name)
public static long notNegative(long n, String name)
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");
T
- the object typeargument
- the object to checkname
- the String
exception message if invalid, not nullnull
for method chaining)NullPointerException
- if the object is null
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
object
- the Object
to test, may be null
true
if the object has a supported type and is empty or null,
false
otherwisepublic static int positive(int n, String name)
public static long positive(long n, String name)
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.