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
getmethod that simply returns the instance itself.The rest of the methods in this interface are static factory methods that allow creation of a
Nullablevalues from various primitive, wrapper and reference types, as well as a staticget(Nullable)method that allows you to "unwrap" anyNullableand return either the value itself or anull, if the specifiedNullableis 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 emptyNullablevalue.default Tget()Return the raw value of thisNullable.static <T> Tget(Nullable<? extends T> value)Return the value of the specifiedNullable.static Nullable<Boolean>of(boolean value)Create aNullablerepresentation of the specifiedbooleanvalue.static Nullable<Byte>of(byte value)Create aNullablerepresentation of the specifiedbytevalue.static Nullable<Double>of(double value)Create aNullablerepresentation of the specifieddoublevalue.static Nullable<Float>of(float value)Create aNullablerepresentation of the specifiedfloatvalue.static Nullable<Integer>of(int value)Create aNullablerepresentation of the specifiedintvalue.static Nullable<Long>of(long value)Create aNullablerepresentation of the specifiedlongvalue.static Nullable<Short>of(short value)Create aNullablerepresentation of the specifiedshortvalue.static Nullable<Boolean>of(Boolean value)Create aNullablerepresentation of the specifiedBooleanvalue.static Nullable<Byte>of(Byte value)Create aNullablerepresentation of the specifiedBytevalue.static Nullable<Double>of(Double value)Create aNullablerepresentation of the specifiedDoublevalue.static Nullable<Float>of(Float value)Create aNullablerepresentation of the specifiedFloatvalue.static Nullable<Integer>of(Integer value)Create aNullablerepresentation of the specifiedIntegervalue.static Nullable<Long>of(Long value)Create aNullablerepresentation of the specifiedLongvalue.static Nullable<Short>of(Short value)Create aNullablerepresentation of the specifiedShortvalue.static <T> Nullable<T>of(T value)Create aNullablerepresentation of the specified reference value.
-
-
-
Method Detail
-
of
static <T> Nullable<T> of(T value)
Create aNullablerepresentation of the specified reference value.- Type Parameters:
T- the type of wrapped reference value- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Integer> of(int value)
Create aNullablerepresentation of the specifiedintvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Integer> of(Integer value)
Create aNullablerepresentation of the specifiedIntegervalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Long> of(long value)
Create aNullablerepresentation of the specifiedlongvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Long> of(Long value)
Create aNullablerepresentation of the specifiedLongvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Short> of(short value)
Create aNullablerepresentation of the specifiedshortvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Short> of(Short value)
Create aNullablerepresentation of the specifiedShortvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Byte> of(byte value)
Create aNullablerepresentation of the specifiedbytevalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Byte> of(Byte value)
Create aNullablerepresentation of the specifiedBytevalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Double> of(double value)
Create aNullablerepresentation of the specifieddoublevalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Double> of(Double value)
Create aNullablerepresentation of the specifiedDoublevalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Float> of(float value)
Create aNullablerepresentation of the specifiedfloatvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Float> of(Float value)
Create aNullablerepresentation of the specifiedFloatvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Boolean> of(boolean value)
Create aNullablerepresentation of the specifiedbooleanvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
of
static Nullable<Boolean> of(Boolean value)
Create aNullablerepresentation of the specifiedBooleanvalue.- Parameters:
value- the value to create aNullablefor- Returns:
- a
Nullablerepresentation of the specified value
-
empty
static <T> Nullable<T> empty()
Create an emptyNullablevalue.- Returns:
- an empty
Nullable
-
get
static <T> T get(Nullable<? extends T> value)
Return the value of the specifiedNullable.- Type Parameters:
T- the type ofNullablevalue- Parameters:
value- theNullablevalue to get the value from- Returns:
- the value of the specified
Nullable, ornullif theNullableis empty
-
get
default T get()
Return the raw value of thisNullable.- Returns:
- the raw value of this
Nullable
-
-