Class NullableDataKey<T>

    • Constructor Detail

      • NullableDataKey

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

        public NullableDataKey​(@NotNull
                               java.lang.String name,
                               @Nullable
                               T defaultValue)
      • NullableDataKey

        public NullableDataKey​(@NotNull
                               java.lang.String name)
        Create a DataKey with null default value and factory producing null values
        Parameters:
        name - key name