public abstract class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static Double |
doubleOrNull(String value) |
static boolean |
isNotNullAndNotEmpty(String value)
Returns true if the input string is not null and it is not empty.
|
static boolean |
isNullOrEmpty(String value)
Returns true if the input string is null or is empty.
|
static <T> Collection<T> |
notNullOrEmpty(Collection<T> values)
Returns the same input collection if that is not null, otherwise a new empty collection.
|
static <T> List<T> |
notNullOrEmpty(List<T> values)
Returns the same input list if that is not null, otherwise a new empty list.
|
static void |
silentyClose(Closeable resource)
Silently closes the given
Closeable resource without raising any exception. |
static boolean |
startsWithLanguageMarker(String value)
Returns true if the first character of the input string is the locale marker character.
|
static Integer |
toIntOrNull(String value)
Converts the given input in an Integer, otherwise it returns null.
|
public static <T> Collection<T> notNullOrEmpty(Collection<T> values)
T - the collection type.values - the collection.public static <T> List<T> notNullOrEmpty(List<T> values)
T - the list elements type.values - the input list.public static Integer toIntOrNull(String value)
value - the numeric string.public static void silentyClose(Closeable resource)
Closeable resource without raising any exception.
This utility method is specifically useful when we have to close a resource in a lamba statement: since the
close() method could throw an IOException the compiler requires an enclosing try / catch block which
makes the code less readable.
try { if (resource != null) resource.close } catch (IOException exception) { ... }
silentlyClose(resource);
resource - the Closeable resource we want to silently close.public static boolean isNullOrEmpty(String value)
value - the input string.public static boolean isNotNullAndNotEmpty(String value)
value - the input string.public static boolean startsWithLanguageMarker(String value)
value - the input string.Copyright © 2005–2020 Alfresco Software. All rights reserved.