Package com.ontology2.pidove.util
Class Null
java.lang.Object
com.ontology2.pidove.util.Null
Functions for handling nulls
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <X> X
coalesce
(X a, X b) Null coalescing operator returns the first argument that isn't null or null if all arguments are null.static <X> X
coalesce
(X a, X b, X c) static <X> X
coalesce
(X a, X b, X c, X... d) Null coalescing operator Since all the values are the same type this can be implemented for an arbitrary number of values with varargsstatic <X,
Y> Y Safe navigation operator.static <X,
Y, Z> Z static <X,
Y, Z, ZZ> ZZ static <X> void
Safe navigation operator.static <X,
Y> void static <X,
Y, Z> void
-
Constructor Details
-
Null
public Null()
-
-
Method Details
-
coalesce
public static <X> X coalesce(X a, X b) Null coalescing operator returns the first argument that isn't null or null if all arguments are null.- Type Parameters:
X
- the return data type- Parameters:
a
- a value of type ab
- a value of type b- Returns:
- a if a is not null otherwise b
-
coalesce
public static <X> X coalesce(X a, X b, X c) -
coalesce
Null coalescing operator Since all the values are the same type this can be implemented for an arbitrary number of values with varargs- Type Parameters:
X
- the returned data type- Parameters:
a
- first valueb
- second valuec
- third valued
- more arguments...- Returns:
- the first non-null value.
-
safe
Safe navigation operator. If x is null returns null, otherwise applies f1 to x. Longer variants apply any functions that occur in later arguments, doing the null check each time.- Type Parameters:
X
- input typeY
- output type- Parameters:
x
- input valuef1
- function that can be applied to x- Returns:
- null if x is null, otherwise f(x).
-
safe0
Safe navigation operator. If x is null does nothing. If x is not null, makes f1 accept x. Longer variants apply functions in series if the result is not null, finally making the Consumer passed as the last argument accepting that result if it is not null- Type Parameters:
X
- input type- Parameters:
x
- input valuef1
- consumer that can accept x
-
safe
-
safe0
-
safe
-
safe0
-