Package com.oracle.coherence.common.base
Interface Nullable<T>
- All Known Implementing Classes:
Binary
,InflatableSet
public interface Nullable<T>
An interface that any class can implement to mark itself as "nullable",
which allows it to be used in a more optimal way with collections that
support "nullable" keys and/or values.
While technically not a marker interface, this interface can typically be
used as such as it provides a reasonable default implementation of the
get
method that simply returns the instance itself.
The rest of the methods in this interface are static factory methods that
allow creation of a Nullable
values from various primitive, wrapper
and reference types, as well as a static get(Nullable)
method that allows you to "unwrap" any Nullable
and return either
the value itself or a null
, if the specified Nullable
is
empty.
- Since:
- 24.03
- Author:
- Aleks Seovic 2024.01.08
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Nullable
<T> empty()
Create an emptyNullable
value.default T
get()
Return the raw value of thisNullable
.static <T> T
Return the value of the specifiedNullable
.of
(boolean value) Create aNullable
representation of the specifiedboolean
value.of
(byte value) Create aNullable
representation of the specifiedbyte
value.of
(double value) Create aNullable
representation of the specifieddouble
value.of
(float value) Create aNullable
representation of the specifiedfloat
value.of
(int value) Create aNullable
representation of the specifiedint
value.of
(long value) Create aNullable
representation of the specifiedlong
value.of
(short value) Create aNullable
representation of the specifiedshort
value.Create aNullable
representation of the specifiedBoolean
value.Create aNullable
representation of the specifiedByte
value.Create aNullable
representation of the specifiedDouble
value.Create aNullable
representation of the specifiedFloat
value.Create aNullable
representation of the specifiedInteger
value.Create aNullable
representation of the specifiedLong
value.Create aNullable
representation of the specifiedShort
value.static <T> Nullable
<T> of
(T value) Create aNullable
representation of the specified reference value.
-
Method Details
-
of
Create aNullable
representation of the specified reference value.- Type Parameters:
T
- the type of wrapped reference value- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedint
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedInteger
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedlong
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedLong
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedshort
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedShort
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedbyte
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedByte
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifieddouble
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedDouble
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedfloat
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedFloat
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedboolean
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
Create aNullable
representation of the specifiedBoolean
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
empty
Create an emptyNullable
value.- Returns:
- an empty
Nullable
-
get
Return the value of the specifiedNullable
.- Type Parameters:
T
- the type ofNullable
value- Parameters:
value
- theNullable
value to get the value from- Returns:
- the value of the specified
Nullable
, ornull
if theNullable
is empty
-
get
Return the raw value of thisNullable
.- Returns:
- the raw value of this
Nullable
-