Top Description Constructors Methods
com.vladsch.flexmark.util.data

public Class DataKey<T>

extends DataKeyBase<T>
Class Inheritance
Type Parameters
<T>
type of data held by the key
Imports
org.jetbrains.annotations.NotNull, .Nullable

Note

Constructors have changed in a breaking way from 0.50.x and prior implementations

Previously you could provide:

1. [T] defaultValue 2. DataValueFactory[T] 3. DataKey[T]

Options 1. and 2. are not available separately and both have to be provided to the constructor to eliminate the need for handling null for DataHolder in the data value factory.

Now you have the following choices:

1. [T] defaultValue AND DataNotNullValueFactory 2. NotNullValueSupplier[T] 3. DataKey[T] from which default value will be taken on construction, and values will be retrieved if no value is set for this key

Additional changes include separating NullableDataKey out so that DataKey values cannot be null. If you need a key with null result value then use NullableDataKey which is identical to DataKey but allows nulls to be used for values.

Constructor Summary

AccessConstructor and Description
public
DataKey(@NotNull String name, T
default to use when data holder is null
defaultValue
,
@NotNull DataNotNullValueFactory<T>
data value factory for creating a new default value for the key for a non-null data holder
factory
)

Creates a DataKey with non-null data value and factory

Use this constructor to ensure that factory is never called with null data holder value

public
DataKey(@NotNull String name, @NotNull NotNullValueSupplier<T>
data value factory for creating a new default value for the key not dependent on dataHolder
supplier
)

Creates a DataKey with non-null data value and factory

Use this constructor to ensure that factory is never called with null data holder value

public
DataKey(@NotNull String name, @NotNull DataKey<T>
The NullableDataKey to take the default value from at time of construction.
defaultKey
)

Creates a DataKey with a dynamic default value taken from a value of another key

does not cache the returned default value but will always delegate to another key until this key gets its own value set.

public
DataKey(@NotNull String name, T defaultValue)

Method Summary

Modifier and TypeMethod and Description
public T
public T
public T
public @NotNull DataNotNullValueFactory<T>
public @NotNull MutableDataHolder
set(@NotNull MutableDataHolder dataHolder, T value)

public String
toString()

Overrides com.vladsch.flexmark.util.data.DataKeyBase.toString.

Returns a string representation of the object.

Inherited from com.vladsch.flexmark.util.data.DataKeyBase:
equalsgetgetDefaultValuegetFromgetNamehashCode

Constructor Detail

DataKeyback to summary
public DataKey(@NotNull String name, T defaultValue, @NotNull DataNotNullValueFactory<T> factory)

Creates a DataKey with non-null data value and factory

Use this constructor to ensure that factory is never called with null data holder value

Parameters
name:@NotNull String

See getName().

defaultValue:T

default to use when data holder is null

factory:@NotNull DataNotNullValueFactory<T>

data value factory for creating a new default value for the key for a non-null data holder

DataKeyback to summary
public DataKey(@NotNull String name, @NotNull NotNullValueSupplier<T> supplier)

Creates a DataKey with non-null data value and factory

Use this constructor to ensure that factory is never called with null data holder value

Parameters
name:@NotNull String

See getName().

supplier:@NotNull NotNullValueSupplier<T>

data value factory for creating a new default value for the key not dependent on dataHolder

DataKeyback to summary
public DataKey(@NotNull String name, @NotNull DataKey<T> defaultKey)

Creates a DataKey with a dynamic default value taken from a value of another key

does not cache the returned default value but will always delegate to another key until this key gets its own value set.

Parameters
name:@NotNull String

See getName().

defaultKey:@NotNull DataKey<T>

The NullableDataKey to take the default value from at time of construction.

DataKeyback to summary
public DataKey(@NotNull String name, T defaultValue)

Method Detail

getback to summary
public T get(@Nullable DataHolder holder)
Annotations
@NotNull
getDefaultValueback to summary
public T getDefaultValue()

Overrides com.vladsch.flexmark.util.data.DataKeyBase.getDefaultValue.

Annotations
@NotNull
getDefaultValueback to summary
public T getDefaultValue(@NotNull DataHolder holder)
Annotations
@NotNull
getFactoryback to summary
public @NotNull DataNotNullValueFactory<T> getFactory()

Overrides com.vladsch.flexmark.util.data.DataKeyBase.getFactory.

Annotations
@NotNull
setback to summary
public @NotNull MutableDataHolder set(@NotNull MutableDataHolder dataHolder, T value)
Annotations
@Override
@NotNull
toStringback to summary
public String toString()

Overrides com.vladsch.flexmark.util.data.DataKeyBase.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override