|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.xenqtt.XenqttUtil
public final class XenqttUtil
Provides disparate utility methods useful across the Xenqtt application ecosystem.
| Method Summary | ||
|---|---|---|
static String[] |
quickSplit(String value,
char delimiter)
Split a string using a single delimiter. |
|
static
|
validateGreaterThan(String name,
T value,
T max)
Validate that a number is greater than a defined maximum. |
|
static
|
validateGreaterThanOrEqualTo(String name,
T value,
T max)
Validate that a number is greater than or equal to a defined maximum. |
|
static
|
validateInRange(String name,
T value,
T start,
T end)
Validate that a number falls within a specific range. |
|
static
|
validateLessThan(String name,
T value,
T max)
Validate that a number is less than a defined maximum. |
|
static
|
validateLessThanOrEqualTo(String name,
T value,
T max)
Validate that a number is less than or equal to a defined maximum. |
|
static
|
validateNotEmpty(String name,
Collection<T> value)
Validate that an arbitrary collection of objects of type T is not empty. |
|
static String |
validateNotEmpty(String name,
String value)
Validate that a string is not empty. |
|
static
|
validateNotEmpty(String name,
T[] value)
Validate that an arbitrary array of objects of type T is not empty. |
|
static
|
validateNotNull(String name,
T value)
Validates that an object is not null. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String[] quickSplit(String value,
char delimiter)
Split a string using a single delimiter. This method is useful in cases where one needs to split a string on a single character and
desires optimal performance. The String.split(String) method builds a regular expression under the covers and, as a result, performs worse than
this method does for the single character use case.
With respect to this method and the given input parameters, the following holds:
XenqttUtil.quickSplit("abcd", '/') ==> {"abcd"}XenqttUtil.quickSplit("ab/cd", '/') ==> {"ab", "cd"}XenqttUtil.quickSplit("a/b/c/d", '/') ==> {"a", "b", "c", "d"}XenqttUtil.quickSplit("/ab/cd", '/') ==> {"ab", "cd"}XenqttUtil.quickSplit("ab/cd/", '/') ==> {"ab", "cd"}XenqttUtil.quickSplit("/ab/cd/", '/') ==> {"ab", "cd"}XenqttUtil.quickSplit("///a//bc////d///////", '/') ==> {"a", "bc", "d"}XenqttUtil.quickSplit("///////", '/') ==> {}XenqttUtil.quickSplit("", '/') ==> {}XenqttUtil.quickSplit(null, '/') ==> {}
value - The string value that should be splitdelimiter - The delimiter to split the specified value on
value on the specified delimiter
public static <T> T validateNotNull(String name,
T value)
null.
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The object to validate
value
IllegalArgumentException - If value is null
public static String validateNotEmpty(String name,
String value)
string is not empty. An empty string is either null or the empty string. Having only whitespace in the string (
\r \n \t ' ') constitutes an empty string as well.
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The string to validate
value
IllegalArgumentException - If value is an empty string
public static <T> T[] validateNotEmpty(String name,
T[] value)
T is not empty. The array is considered empty if it is null or contains zero
elements.
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The array to validate
value
IllegalArgumentException - If value is null or contains no elements
public static <T> Collection<T> validateNotEmpty(String name,
Collection<T> value)
collection of objects of type T is not empty. The collection is considered empty if it is
null or contains zero elements.
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The collection to validate
value
IllegalArgumentException - If value is null or contains no elements
public static <T extends Number> T validateLessThan(String name,
T value,
T max)
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The value of the numbermax - The maximum that the specified value must be under
value
IllegalArgumentException - If value is null or is greater than or equal to max
public static <T extends Number> T validateLessThanOrEqualTo(String name,
T value,
T max)
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The value of the numbermax - The maximum that the specified value must be under
value
IllegalArgumentException - If value is null or is greater than max
public static <T extends Number> T validateGreaterThan(String name,
T value,
T max)
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The value of the numbermax - The maximum that the specified value must be over
value
IllegalArgumentException - If value is null or is less than or equal to max
public static <T extends Number> T validateGreaterThanOrEqualTo(String name,
T value,
T max)
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The value of the numbermax - The maximum that the specified value must be over
value
IllegalArgumentException - If value is null or is less than or equal to max
public static <T extends Number> T validateInRange(String name,
T value,
T start,
T end)
name - The name of the object being validated. Included in the exception message if one is thrownvalue - The value of the numberstart - The start of the rangeend - The end of the range
value
IllegalArgumentException - If value is null or falls outside of the range specified by start and end
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||