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 booleanisNullOrEmpty(com.fasterxml.jackson.databind.JsonNode node)static booleanisNullOrEmpty(Object[] array)Check whether the given array is eithernullor empty (i.e., has zero length).static booleanisNullOrEmpty(String string)Check whether the given text value is eithernullor empty (i.e., has zero length).static booleanisNullOrEmpty(Collection<?> collection)Check whether the given collection is eithernullor empty (i.e., has zero size).static <T> List<T>nullSafe(List<T> list)Ensure the given list into aListcontaining its items.static <T> List<T>nullSafe(T[] array)Convert the given array into aListcontaining its items.static booleannullSafeEquals(Object one, Object other)Ensure the two given values are either bothnullor equal to each other.
-
-
-
Method Detail
-
isNullOrEmpty
public static boolean isNullOrEmpty(String string)
Check whether the given text value is eithernullor 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 eithernullor 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 eithernullor 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 aListcontaining its items. If the given array isnull, an emptyListis 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 aListcontaining its items. If the given array isnull, an emptyListis being returned.- Type Parameters:
T- type of list items- Parameters:
list- the list to convert (may benull- Returns:
- non-
nulllist instance
-
-