Modifier and Type | Method and Description |
---|---|
static <T> T |
ensureNonNull(T value)
Get value if it is not null.
|
static <T> T |
ensureNonNull(T value,
T defaultValue)
Get value and ensure that the value is not null
|
static String |
ensureNonNullAndNonEmpty(String value,
String dflt)
Get non-null non-empty string.
|
static String |
ensureNonNullStr(String value)
Ensure that a string will not be null.
|
static <T> T |
findFirstNonNull(T... objects)
Find the first non-null value in an array and return that.
|
public static <T> T ensureNonNull(T value, T defaultValue)
T
- type of valuevalue
- the valuedefaultValue
- the default value to be returned if the value is nullAssertionError
- if both the value and the default value are nullpublic static <T> T ensureNonNull(T value)
T
- type of valuevalue
- the valueAssertionError
- if the value is nullpublic static <T> T findFirstNonNull(T... objects)
T
- type of valueobjects
- array to find valueAssertionError
- if the array is null or it doesn't contain a
non-null valuepublic static String ensureNonNullAndNonEmpty(String value, @Constraint(value="notEmpty(X)") String dflt)
value
- a base stringdflt
- default string to be provided if value is null or emptyCopyright © 2011–2020 Igor Maznitsa. All rights reserved.