Package org.hibernate.internal.util
Class NullnessHelper
- java.lang.Object
- org.hibernate.internal.util.NullnessHelper
public classNullnessHelperextendsObject
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareAllNonNull(Object... objects)static booleanareSameNullness(Object... values)Ensures that either: all values are null all values are non-nullstatic <T> Tcoalesce(T... values)Operates like SQL coalesce expression, returning the first non-empty valuestatic <T> TcoalesceSuppliedValues(Function<T,Boolean> checker,Supplier<T>... valueSuppliers)Operates like SQL coalesce expression, returning the first non-empty valuestatic <T> TcoalesceSuppliedValues(Supplier<T>... valueSuppliers)Operates like SQL coalesce expression, returning the first non-empty valuestatic <T> Tnullif(T test,Supplier<T> fallbackSupplier)static <T> Tnullif(T test, T fallback)
Method Detail
nullif
public static <T> T nullif(T test, T fallback)
nullif
public static <T> T nullif(T test,Supplier<T> fallbackSupplier)
coalesce
@SafeVarargspublic 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
@SafeVarargspublic 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
@SafeVarargspublic 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)