Package com.vladsch.flexmark.util.data
Class NullableDataKey<T>
- java.lang.Object
-
- com.vladsch.flexmark.util.data.DataKeyBase<T>
-
- com.vladsch.flexmark.util.data.NullableDataKey<T>
-
- All Implemented Interfaces:
MutableDataValueSetter<T>
public class NullableDataKey<T> extends DataKeyBase<T>
-
-
Constructor Summary
Constructors Constructor Description NullableDataKey(@NotNull String name)Create a DataKey with null default value and factory producing null valuesNullableDataKey(@NotNull String name, @NotNull DataKeyBase<T> defaultKey)Creates a NullableDataKey with a dynamic default value taken from a value of another keyNullableDataKey(@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 holderNullableDataKey(@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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget(@Nullable DataHolder holder)TgetDefaultValue()TgetDefaultValue(@NotNull DataHolder holder)@NotNull MutableDataHolderset(@NotNull MutableDataHolder dataHolder, T value)StringtoString()-
Methods inherited from class com.vladsch.flexmark.util.data.DataKeyBase
equals, getFactory, getFrom, getName, hashCode
-
-
-
-
Constructor Detail
-
NullableDataKey
public NullableDataKey(@NotNull @NotNull String name, @Nullable T defaultValue, @NotNull @NotNull DataValueFactory<T> factory)Creates a DataKey with nullable data value and factory with non-nullable dataHolderUse this constructor to ensure that factory is never called with null data holder value
- Parameters:
name- SeeDataKeyBase.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 holder
-
NullableDataKey
public NullableDataKey(@NotNull @NotNull String name, @NotNull @NotNull DataValueNullableFactory<T> factory)Creates a DataKey with a computed default value dynamically.On construction will invoke factory with null data holder to get the default value
- Parameters:
name- SeeDataKeyBase.getName().factory- data value factory for creating a new default value for the key
-
NullableDataKey
public NullableDataKey(@NotNull @NotNull String name, @NotNull @NotNull Supplier<T> supplier)Creates a DataKey with nullable data value and factory not dependent on data holderUse this constructor to ensure that factory is never called with null data holder value
- Parameters:
name- SeeDataKeyBase.getName().supplier- data value factory for creating a new default value for the key not dependent on dataHolder
-
NullableDataKey
public NullableDataKey(@NotNull @NotNull String name, @NotNull @NotNull DataKeyBase<T> defaultKey)Creates a NullableDataKey with a dynamic default value taken from a value of another keydoes not cache the returned default value but will always delegate to another key until this key gets its own value set.
- Parameters:
name- SeeDataKeyBase.getName().defaultKey- The NullableDataKey to take the default value from at time of construction.
-
NullableDataKey
public NullableDataKey(@NotNull @NotNull String name)Create a DataKey with null default value and factory producing null values- Parameters:
name- key name
-
-
Method Detail
-
getDefaultValue
@Nullable public T getDefaultValue()
- Overrides:
getDefaultValuein classDataKeyBase<T>
-
getDefaultValue
@Nullable public T getDefaultValue(@NotNull @NotNull DataHolder holder)
- Overrides:
getDefaultValuein classDataKeyBase<T>
-
get
@Nullable public T get(@Nullable @Nullable DataHolder holder)
- Overrides:
getin classDataKeyBase<T>
-
set
@NotNull public @NotNull MutableDataHolder set(@NotNull @NotNull MutableDataHolder dataHolder, @Nullable T value)
-
toString
public String toString()
- Overrides:
toStringin classDataKeyBase<T>
-
-