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

public abstract Class DataKeyBase<T>

extends Object
implements MutableDataValueSetter<T>
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.util.data.MutableDataValueSetter
Known Direct Subclasses
com.vladsch.flexmark.util.data.NullableDataKey, com.vladsch.flexmark.util.data.DataKey
Imports
org.jetbrains.annotations.NotNull, .Nullable

Field Summary

Modifier and TypeField and Description
private final T
private final @NotNull DataValueFactory<T>
private final @NotNull String

Constructor Summary

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

Creates a NullableDataKey with a computed default value and a provided default value when data holder is null.

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

Creates a NullableDataKey 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
DataKeyBase(@NotNull String name, T defaultValue)

Method Summary

Modifier and TypeMethod and Description
public final boolean

Returns:

true if equal
equals
(Object
other
o
)

Overrides java.lang.Object.equals.

Compare only by address.

public T
public T
public T
public @NotNull DataValueFactory<T>
public final T

Returns:

return default value if holder is null, current value in holder or compute a new value
getFrom
(@Nullable DataHolder
data holder
holder
)
Deprecated use get

public @NotNull String
public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

defaultValueback to summary
private final T defaultValue
factoryback to summary
private final @NotNull DataValueFactory<T> factory
Annotations
@NotNull
nameback to summary
private final @NotNull String name
Annotations
@NotNull

Constructor Detail

DataKeyBaseback to summary
public 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.

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 DataValueFactory<T>

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

DataKeyBaseback to summary
public DataKeyBase(@NotNull String name, @NotNull DataKeyBase<T> defaultKey)

Creates a NullableDataKey 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 DataKeyBase<T>

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

DataKeyBaseback to summary
public DataKeyBase(@NotNull String name, T defaultValue)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Overrides java.lang.Object.equals.

Compare only by address. Every key instance is unique

Parameters
o:Object

other

Returns:boolean

true if equal

Annotations
@Override
getback to summary
public T get(@Nullable DataHolder holder)
getDefaultValueback to summary
public T getDefaultValue()
getDefaultValueback to summary
public T getDefaultValue(@NotNull DataHolder holder)
getFactoryback to summary
public @NotNull DataValueFactory<T> getFactory()
Annotations
@NotNull
getFromback to summary
public final T getFrom(@Nullable DataHolder holder)

Deprecated

use get

Parameters
holder:@Nullable DataHolder

data holder

Returns:T

return default value if holder is null, current value in holder or compute a new value

Annotations
@Deprecated
getNameback to summary
public @NotNull String getName()
Annotations
@NotNull
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.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