public class NullableDataKey<T> extends DataKeyBase<T>
| Constructor and Description |
|---|
NullableDataKey(@NotNull String name)
Create a DataKey with null default value and factory producing null values
|
NullableDataKey(@NotNull String name,
@NotNull DataKeyBase<T> defaultKey)
Creates a NullableDataKey with a dynamic default value taken from a value of another key
|
NullableDataKey(@NotNull String name,
@NotNull DataValueNullableFactory<T> factory)
Creates a DataKey with a computed default value dynamically.
|
NullableDataKey(@NotNull String name,
@NotNull Supplier<T> supplier)
Creates a DataKey with nullable data value and factory not dependent on data holder
|
NullableDataKey(@NotNull String name,
T defaultValue) |
NullableDataKey(@NotNull String name,
T defaultValue,
@NotNull DataValueFactory<T> factory)
Creates a DataKey with nullable data value and factory with non-nullable dataHolder
|
| Modifier and Type | Method and Description |
|---|---|
T |
get(@Nullable DataHolder holder) |
T |
getDefaultValue() |
T |
getDefaultValue(@NotNull DataHolder holder) |
@NotNull MutableDataHolder |
set(@NotNull MutableDataHolder dataHolder,
T value) |
String |
toString() |
equals, getFactory, getFrom, getName, hashCodepublic NullableDataKey(@NotNull
@NotNull String name,
@Nullable
T defaultValue,
@NotNull
@NotNull DataValueFactory<T> factory)
Use this constructor to ensure that factory is never called with null data holder value
name - See DataKeyBase.getName().defaultValue - default to use when data holder is nullfactory - data value factory for creating a new default value for the key for a non-null data holderpublic NullableDataKey(@NotNull
@NotNull String name,
@NotNull
@NotNull DataValueNullableFactory<T> factory)
On construction will invoke factory with null data holder to get the default value
name - See DataKeyBase.getName().factory - data value factory for creating a new default value for the keypublic NullableDataKey(@NotNull
@NotNull String name,
@NotNull
@NotNull Supplier<T> supplier)
Use this constructor to ensure that factory is never called with null data holder value
name - See DataKeyBase.getName().supplier - data value factory for creating a new default value for the key not dependent on dataHolderpublic NullableDataKey(@NotNull
@NotNull String name,
@NotNull
@NotNull DataKeyBase<T> defaultKey)
does not cache the returned default value but will always delegate to another key until this key gets its own value set.
name - See DataKeyBase.getName().defaultKey - The NullableDataKey to take the default value from at time of construction.public NullableDataKey(@NotNull
@NotNull String name)
name - key name@Nullable public T getDefaultValue()
getDefaultValue in class DataKeyBase<T>@Nullable public T getDefaultValue(@NotNull @NotNull DataHolder holder)
getDefaultValue in class DataKeyBase<T>@Nullable public T get(@Nullable @Nullable DataHolder holder)
get in class DataKeyBase<T>@NotNull public @NotNull MutableDataHolder set(@NotNull @NotNull MutableDataHolder dataHolder, @Nullable T value)
public String toString()
toString in class DataKeyBase<T>Copyright © 2020. All rights reserved.