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(java.lang.String name)
Create a DataKey with null default value and factory producing null valuesNullableDataKey(java.lang.String name, DataKeyBase<T> defaultKey)
Creates a NullableDataKey with a dynamic default value taken from a value of another keyNullableDataKey(java.lang.String name, DataValueNullableFactory<T> factory)
Creates a DataKey with a computed default value dynamically.NullableDataKey(java.lang.String name, java.util.function.Supplier<T> supplier)
Creates a DataKey with nullable data value and factory not dependent on data holderNullableDataKey(java.lang.String name, T defaultValue)
NullableDataKey(java.lang.String name, T defaultValue, 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 T
get(DataHolder holder)
T
getDefaultValue()
T
getDefaultValue(DataHolder holder)
MutableDataHolder
set(MutableDataHolder dataHolder, T value)
java.lang.String
toString()
-
Methods inherited from class com.vladsch.flexmark.util.data.DataKeyBase
equals, getFactory, getFrom, getName, hashCode
-
-
-
-
Constructor Detail
-
NullableDataKey
public NullableDataKey(@NotNull java.lang.String name, @Nullable T defaultValue, @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 java.lang.String name, @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 java.lang.String name, @NotNull java.util.function.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 java.lang.String name, @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 java.lang.String name, @Nullable T defaultValue)
-
NullableDataKey
public NullableDataKey(@NotNull java.lang.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:
getDefaultValue
in classDataKeyBase<T>
-
getDefaultValue
@Nullable public T getDefaultValue(@NotNull DataHolder holder)
- Overrides:
getDefaultValue
in classDataKeyBase<T>
-
get
@Nullable public T get(@Nullable DataHolder holder)
- Overrides:
get
in classDataKeyBase<T>
-
set
@NotNull public MutableDataHolder set(@NotNull MutableDataHolder dataHolder, @Nullable T value)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classDataKeyBase<T>
-
-