|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.cloudera.lib.util.Check
public class Check
Utility methods to check preconditions.
Commonly used for method arguments preconditions.
| Constructor Summary | |
|---|---|
Check()
|
|
| Method Summary | ||
|---|---|---|
static int |
ge0(int value,
String name)
Verifies an integer is greater or equal to zero. |
|
static long |
ge0(long value,
String name)
Verifies an long is greater or equal to zero. |
|
static int |
gt0(int value,
String name)
Verifies an integer is greater than zero. |
|
static long |
gt0(long value,
String name)
Verifies an long is greater than zero. |
|
static String |
notEmpty(String str,
String name)
Verifies a string is not NULL and not emtpy |
|
static List<String> |
notEmptyElements(List<String> list,
String name)
Verifies a string list is not NULL and not emtpy |
|
static
|
notNull(T obj,
String name)
Verifies a variable is not NULL. |
|
static
|
notNullElements(List<T> list,
String name)
Verifies a list does not have any NULL elements. |
|
static String |
validIdentifier(String value,
int maxLen,
String name)
Verifies a value is a valid identifier, [a-zA-z_][a-zA-Z0-9_\-]*, up to a maximum length. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Check()
| Method Detail |
|---|
public static <T> T notNull(T obj,
String name)
obj - the variable to check.name - the name to use in the exception message.
IllegalArgumentException - if the variable is NULL.
public static <T> List<T> notNullElements(List<T> list,
String name)
list - the list to check.name - the name to use in the exception message.
IllegalArgumentException - if the list has NULL elements.
public static String notEmpty(String str,
String name)
str - the variable to check.name - the name to use in the exception message.
IllegalArgumentException - if the variable is NULL or empty.
public static List<String> notEmptyElements(List<String> list,
String name)
list - the list to check.name - the name to use in the exception message.
IllegalArgumentException - if the string list has NULL or empty
elements.
public static String validIdentifier(String value,
int maxLen,
String name)
[a-zA-z_][a-zA-Z0-9_\-]*, up to a maximum length.
value - string to check if it is a valid identifier.maxLen - maximun length.name - the name to use in the exception message.
IllegalArgumentException - if the string is not a valid identifier.
public static int gt0(int value,
String name)
value - integer value.name - the name to use in the exception message.
IllegalArgumentException - if the integer is zero or less.
public static long gt0(long value,
String name)
value - long value.name - the name to use in the exception message.
IllegalArgumentException - if the long is zero or less.
public static int ge0(int value,
String name)
value - integer value.name - the name to use in the exception message.
IllegalArgumentException - if the integer is greater or equal to zero.
public static long ge0(long value,
String name)
value - integer value.name - the name to use in the exception message.
IllegalArgumentException - if the long is greater or equal to zero.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||