Top Constructors Methods
org.hibernate.internal.util

public Class NullnessHelper

extends Object
Class Inheritance
Imports
java.util.function.Function, .Supplier

Author
Steve Ebersole

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
areAllNonNull(Object... objects)

public static boolean
areSameNullness(Object... values)

Ensures that either:

  • all values are null
  • all values are non-null
public static <
Generic type of values to coalesce
T
>
T

Returns:

The first non-empty value, or null if all values were empty
coalesce
(T...
The list of values.
values
)

Operates like SQL coalesce expression, returning the first non-empty value

public static <
Generic type of values to coalesce
T
>
T

Returns:

The first non-empty value, or null if all values were empty
coalesceSuppliedValues
(Supplier<T>...
List of value Suppliers
valueSuppliers
)

Operates like SQL coalesce expression, returning the first non-empty value

public static <
Generic type of values to coalesce
T
>
T

Returns:

The first non-empty value, or null if all values were empty
coalesceSuppliedValues
(Function<T, Boolean> checker, Supplier<T>...
List of value Suppliers
valueSuppliers
)

Operates like SQL coalesce expression, returning the first non-empty value

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

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NullnessHelperback to summary
private NullnessHelper()

Method Detail

areAllNonNullback to summary
public static boolean areAllNonNull(Object... objects)
areSameNullnessback to summary
public static boolean areSameNullness(Object... values)

Ensures that either:

  • all values are null
  • all values are non-null
coalesceback to summary
public static <T> T coalesce(T... values)

Operates like SQL coalesce expression, returning the first non-empty value

Implementation Note

This impl treats empty strings (`""`) as null.

Parameters
<T>
Generic type of values to coalesce
values:T[]

The list of values.

Returns:T

The first non-empty value, or null if all values were empty

Annotations
@SafeVarargs
coalesceSuppliedValuesback to summary
public static <T> T coalesceSuppliedValues(Supplier<T>... valueSuppliers)

Operates like SQL coalesce expression, returning the first non-empty value

Implementation Note

This impl treats empty strings (`""`) as null.

Parameters
<T>
Generic type of values to coalesce
valueSuppliers:Supplier<T>[]

List of value Suppliers

Returns:T

The first non-empty value, or null if all values were empty

Annotations
@SafeVarargs
coalesceSuppliedValuesback to summary
public static <T> T coalesceSuppliedValues(Function<T, Boolean> checker, Supplier<T>... valueSuppliers)

Operates like SQL coalesce expression, returning the first non-empty value

Implementation Note

This impl treats empty strings (`""`) as null.

Parameters
<T>
Generic type of values to coalesce
valueSuppliers:Supplier<T>[]

List of value Suppliers

Returns:T

The first non-empty value, or null if all values were empty

Annotations
@SafeVarargs
nullifback to summary
public static <T> T nullif(T test, T fallback)
nullifback to summary
public static <T> T nullif(T test, Supplier<T> fallbackSupplier)