Class Util
- java.lang.Object
-
- com.github.victools.jsonschema.generator.impl.Util
-
public final class Util extends Object
Utility class offering various helper functions to simplify common checks, e.g., with the goal reduce the complexity of checks and conditions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isNullOrEmpty(com.fasterxml.jackson.databind.JsonNode node)
static boolean
isNullOrEmpty(Object[] array)
Check whether the given array is eithernull
or empty (i.e., has zero length).static boolean
isNullOrEmpty(String string)
Check whether the given text value is eithernull
or empty (i.e., has zero length).static boolean
isNullOrEmpty(Collection<?> collection)
Check whether the given collection is eithernull
or empty (i.e., has zero size).static <T> List<T>
nullSafe(List<T> list)
Ensure the given list into aList
containing its items.static <T> List<T>
nullSafe(T[] array)
Convert the given array into aList
containing its items.static boolean
nullSafeEquals(Object one, Object other)
Ensure the two given values are either bothnull
or equal to each other.
-
-
-
Method Detail
-
isNullOrEmpty
public static boolean isNullOrEmpty(String string)
Check whether the given text value is eithernull
or empty (i.e., has zero length).- Parameters:
string
- the text value to check- Returns:
- check result
-
isNullOrEmpty
public static boolean isNullOrEmpty(com.fasterxml.jackson.databind.JsonNode node)
-
isNullOrEmpty
public static boolean isNullOrEmpty(Object[] array)
Check whether the given array is eithernull
or empty (i.e., has zero length).- Parameters:
array
- the array to check- Returns:
- check result
-
isNullOrEmpty
public static boolean isNullOrEmpty(Collection<?> collection)
Check whether the given collection is eithernull
or empty (i.e., has zero size).- Parameters:
collection
- the collection to check- Returns:
- check result
-
nullSafe
public static <T> List<T> nullSafe(T[] array)
Convert the given array into aList
containing its items. If the given array isnull
, an emptyList
is being returned.- Type Parameters:
T
- type of array items- Parameters:
array
- the array to convert (may benull
- Returns:
- list instance
-
nullSafe
public static <T> List<T> nullSafe(List<T> list)
Ensure the given list into aList
containing its items. If the given array isnull
, an emptyList
is being returned.- Type Parameters:
T
- type of list items- Parameters:
list
- the list to convert (may benull
- Returns:
- non-
null
list instance
-
-