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 Details

    • NullableDataKey

      public NullableDataKey(@NotNull @NotNull String name, @Nullable T defaultValue, @NotNull @NotNull DataValueFactory<T> factory)
      Creates a DataKey with nullable data value and factory with non-nullable dataHolder

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

      Parameters:
      name - See DataKeyBase.getName().
      defaultValue - default to use when data holder is null
      factory - data value factory for creating a new default value for the key for a non-null data holder
    • NullableDataKey

      public NullableDataKey(@NotNull @NotNull String name, @NotNull @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 - See DataKeyBase.getName().
      factory - data value factory for creating a new default value for the key
    • NullableDataKey

      public NullableDataKey(@NotNull @NotNull String name, @NotNull @NotNull Supplier<T> supplier)
      Creates a DataKey with nullable data value and factory not dependent on data holder

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

      Parameters:
      name - See DataKeyBase.getName().
      supplier - data value factory for creating a new default value for the key not dependent on dataHolder
    • NullableDataKey

      public NullableDataKey(@NotNull @NotNull String name, @NotNull @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 - See DataKeyBase.getName().
      defaultKey - The NullableDataKey to take the default value from at time of construction.
    • NullableDataKey

      public NullableDataKey(@NotNull @NotNull String name, @Nullable T defaultValue)
    • NullableDataKey

      public NullableDataKey(@NotNull @NotNull String name)
      Create a DataKey with null default value and factory producing null values
      Parameters:
      name - key name
  • Method Details