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 staticget(Nullable)
method that allows you to "unwrap" anyNullable
and return either the value itself or anull
, if the specifiedNullable
is empty.- Since:
- 24.03
- Author:
- Aleks Seovic 2024.01.08
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <T> Nullable<T>
empty()
Create an emptyNullable
value.default T
get()
Return the raw value of thisNullable
.static <T> T
get(Nullable<? extends T> value)
Return the value of the specifiedNullable
.static Nullable<Boolean>
of(boolean value)
Create aNullable
representation of the specifiedboolean
value.static Nullable<Byte>
of(byte value)
Create aNullable
representation of the specifiedbyte
value.static Nullable<Double>
of(double value)
Create aNullable
representation of the specifieddouble
value.static Nullable<Float>
of(float value)
Create aNullable
representation of the specifiedfloat
value.static Nullable<Integer>
of(int value)
Create aNullable
representation of the specifiedint
value.static Nullable<Long>
of(long value)
Create aNullable
representation of the specifiedlong
value.static Nullable<Short>
of(short value)
Create aNullable
representation of the specifiedshort
value.static Nullable<Boolean>
of(Boolean value)
Create aNullable
representation of the specifiedBoolean
value.static Nullable<Byte>
of(Byte value)
Create aNullable
representation of the specifiedByte
value.static Nullable<Double>
of(Double value)
Create aNullable
representation of the specifiedDouble
value.static Nullable<Float>
of(Float value)
Create aNullable
representation of the specifiedFloat
value.static Nullable<Integer>
of(Integer value)
Create aNullable
representation of the specifiedInteger
value.static Nullable<Long>
of(Long value)
Create aNullable
representation of the specifiedLong
value.static Nullable<Short>
of(Short value)
Create aNullable
representation of the specifiedShort
value.static <T> Nullable<T>
of(T value)
Create aNullable
representation of the specified reference value.
-
-
-
Method Detail
-
of
static <T> Nullable<T> of(T value)
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
static Nullable<Integer> of(int value)
Create aNullable
representation of the specifiedint
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Integer> of(Integer value)
Create aNullable
representation of the specifiedInteger
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Long> of(long value)
Create aNullable
representation of the specifiedlong
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Long> of(Long value)
Create aNullable
representation of the specifiedLong
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Short> of(short value)
Create aNullable
representation of the specifiedshort
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Short> of(Short value)
Create aNullable
representation of the specifiedShort
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Byte> of(byte value)
Create aNullable
representation of the specifiedbyte
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Byte> of(Byte value)
Create aNullable
representation of the specifiedByte
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Double> of(double value)
Create aNullable
representation of the specifieddouble
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Double> of(Double value)
Create aNullable
representation of the specifiedDouble
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Float> of(float value)
Create aNullable
representation of the specifiedfloat
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Float> of(Float value)
Create aNullable
representation of the specifiedFloat
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Boolean> of(boolean value)
Create aNullable
representation of the specifiedboolean
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
of
static Nullable<Boolean> of(Boolean value)
Create aNullable
representation of the specifiedBoolean
value.- Parameters:
value
- the value to create aNullable
for- Returns:
- a
Nullable
representation of the specified value
-
empty
static <T> Nullable<T> empty()
Create an emptyNullable
value.- Returns:
- an empty
Nullable
-
get
static <T> T get(Nullable<? extends T> value)
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
default T get()
Return the raw value of thisNullable
.- Returns:
- the raw value of this
Nullable
-
-