Class Util
java.lang.Object
com.github.victools.jsonschema.generator.impl.Util
Utility class offering various helper functions to simplify common checks, e.g., with the goal reduce the complexity of checks and conditions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 booleanisNullOrEmpty(tools.jackson.databind.JsonNode node) static <T> List<T>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 Details
-
isNullOrEmpty
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(tools.jackson.databind.JsonNode node) -
isNullOrEmpty
Check whether the given array is eithernullor empty (i.e., has zero length).- Parameters:
array- the array to check- Returns:
- check result
-
isNullOrEmpty
Check whether the given collection is eithernullor empty (i.e., has zero size).- Parameters:
collection- the collection to check- Returns:
- check result
-
nullSafe
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
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
-
nullSafeEquals
Ensure the two given values are either bothnullor equal to each other.- Parameters:
one- first value to checkother- second value to check- Returns:
- whether the two given values are equal
-