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
public abstract class DataKeyBase<T> extends java.lang.Object implements MutableDataValueSetter<T>
-
-
Field Summary
Fields Modifier and Type Field Description private TdefaultValueprivate @NotNull DataValueFactory<T>factoryprivate @NotNull java.lang.Stringname
-
Constructor Summary
Constructors Constructor Description DataKeyBase(@NotNull java.lang.String name, @NotNull DataKeyBase<T> defaultKey)Creates a NullableDataKey with a dynamic default value taken from a value of another keyDataKeyBase(@NotNull java.lang.String name, T defaultValue)DataKeyBase(@NotNull java.lang.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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Compare only by address.Tget(@Nullable DataHolder holder)TgetDefaultValue()TgetDefaultValue(@NotNull DataHolder holder)@NotNull DataValueFactory<T>getFactory()TgetFrom(@Nullable DataHolder holder)Deprecated.use get@NotNull java.lang.StringgetName()inthashCode()java.lang.StringtoString()-
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 Detail
-
name
@NotNull private final @NotNull java.lang.String name
-
factory
@NotNull private final @NotNull DataValueFactory<T> factory
-
defaultValue
private final T defaultValue
-
-
Constructor Detail
-
DataKeyBase
public DataKeyBase(@NotNull @NotNull java.lang.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
public DataKeyBase(@NotNull @NotNull java.lang.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- SeegetName().defaultKey- The NullableDataKey to take the default value from at time of construction.
-
DataKeyBase
public DataKeyBase(@NotNull @NotNull java.lang.String name, T defaultValue)
-
-
Method Detail
-
getName
@NotNull public @NotNull java.lang.String getName()
-
getFactory
@NotNull public @NotNull DataValueFactory<T> getFactory()
-
getDefaultValue
public T getDefaultValue()
-
getDefaultValue
public T getDefaultValue(@NotNull @NotNull DataHolder holder)
-
get
public T get(@Nullable @Nullable DataHolder holder)
-
getFrom
@Deprecated public final T getFrom(@Nullable @Nullable DataHolder holder)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object o)
Compare only by address. Every key instance is unique- Overrides:
equalsin classjava.lang.Object- Parameters:
o- other- Returns:
- true if equal
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-