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

    Modifier and Type
    Method
    Description
    static boolean
    Check whether the given array is either null or empty (i.e., has zero length).
    static boolean
    Check whether the given text value is either null or empty (i.e., has zero length).
    static boolean
    isNullOrEmpty(Collection<?> collection)
    Check whether the given collection is either null or empty (i.e., has zero size).
    static boolean
    isNullOrEmpty(tools.jackson.databind.JsonNode node)
     
    static <T> List<T>
    nullSafe(List<T> list)
    Ensure the given list into a List containing its items.
    static <T> List<T>
    nullSafe(T[] array)
    Convert the given array into a List containing its items.
    static boolean
    Ensure the two given values are either both null or equal to each other.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isNullOrEmpty

      public static boolean isNullOrEmpty(String string)
      Check whether the given text value is either null or 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

      public static boolean isNullOrEmpty(Object[] array)
      Check whether the given array is either null 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 either null 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 a List containing its items. If the given array is null, an empty List is being returned.
      Type Parameters:
      T - type of array items
      Parameters:
      array - the array to convert (may be null
      Returns:
      list instance
    • nullSafe

      public static <T> List<T> nullSafe(List<T> list)
      Ensure the given list into a List containing its items. If the given array is null, an empty List is being returned.
      Type Parameters:
      T - type of list items
      Parameters:
      list - the list to convert (may be null
      Returns:
      non-null list instance
    • nullSafeEquals

      public static boolean nullSafeEquals(Object one, Object other)
      Ensure the two given values are either both null or equal to each other.
      Parameters:
      one - first value to check
      other - second value to check
      Returns:
      whether the two given values are equal