Package com.vladsch.flexmark.util.data
Class DataKeyBase<T>
java.lang.Object
com.vladsch.flexmark.util.data.DataKeyBase<T>
- All Implemented Interfaces:
MutableDataValueSetter<T>
- Direct Known Subclasses:
DataKey
,NullableDataKey
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final T
private final @NotNull DataValueFactory
<T> private final @NotNull String
-
Constructor Summary
ConstructorsConstructorDescriptionDataKeyBase
(@NotNull String name, @NotNull DataKeyBase<T> defaultKey) Creates a NullableDataKey with a dynamic default value taken from a value of another keyDataKeyBase
(@NotNull String name, T defaultValue) DataKeyBase
(@NotNull String name, T defaultValue, @NotNull DataValueFactory<T> factory) Creates a NullableDataKey with a computed default value and a provided default value when data holder is null. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Compare only by address.get
(@Nullable DataHolder holder) getDefaultValue
(@NotNull DataHolder holder) @NotNull DataValueFactory
<T> final T
getFrom
(@Nullable DataHolder holder) Deprecated.use get@NotNull String
getName()
final int
hashCode()
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.vladsch.flexmark.util.data.MutableDataValueSetter
set
-
Field Details
-
name
-
factory
-
defaultValue
-
-
Constructor Details
-
DataKeyBase
public DataKeyBase(@NotNull @NotNull String name, T defaultValue, @NotNull @NotNull DataValueFactory<T> factory) Creates a NullableDataKey with a computed default value and a provided default value when data holder is null.Use this constructor to ensure that factory is never called with null data holder value
- Parameters:
name
- SeegetName()
.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
-
DataKeyBase
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
- SeegetName()
.defaultKey
- The NullableDataKey to take the default value from at time of construction.
-
DataKeyBase
-
-
Method Details
-
getName
-
getFactory
-
getDefaultValue
-
getDefaultValue
-
get
-
getFrom
Deprecated.use get- Parameters:
holder
- data holder- Returns:
- return default value if holder is null, current value in holder or compute a new value
-
toString
-
equals
Compare only by address. Every key instance is unique -
hashCode
public final int hashCode()
-