Class NullnessHelper

java.lang.Object
org.hibernate.internal.util.NullnessHelper

public class NullnessHelper extends Object
  • Method Details

    • nullif

      public static <T> T nullif(T test, T fallback)
    • nullif

      public static <T> T nullif(T test, Supplier<T> fallbackSupplier)
    • coalesce

      @SafeVarargs public static <T> T coalesce(T... values)
      Operates like SQL coalesce expression, returning the first non-empty value
      Type Parameters:
      T - Generic type of values to coalesce
      Parameters:
      values - The list of values.
      Returns:
      The first non-empty value, or null if all values were empty
      Implementation Note:
      This impl treats empty strings (`""`) as null.
    • coalesceSuppliedValues

      @SafeVarargs public static <T> T coalesceSuppliedValues(Supplier<T>... valueSuppliers)
      Operates like SQL coalesce expression, returning the first non-empty value
      Type Parameters:
      T - Generic type of values to coalesce
      Parameters:
      valueSuppliers - List of value Suppliers
      Returns:
      The first non-empty value, or null if all values were empty
      Implementation Note:
      This impl treats empty strings (`""`) as null.
    • coalesceSuppliedValues

      @SafeVarargs public static <T> T coalesceSuppliedValues(Function<T,Boolean> checker, Supplier<T>... valueSuppliers)
      Operates like SQL coalesce expression, returning the first non-empty value
      Type Parameters:
      T - Generic type of values to coalesce
      Parameters:
      valueSuppliers - List of value Suppliers
      Returns:
      The first non-empty value, or null if all values were empty
      Implementation Note:
      This impl treats empty strings (`""`) as null.
    • areSameNullness

      public static boolean areSameNullness(Object... values)
      Ensures that either:
      • all values are null
      • all values are non-null
    • areAllNonNull

      public static boolean areAllNonNull(Object... objects)