Interface DataProvider<V extends Value<E>,​E>

    • Method Detail

      • key

        Key<V> key()
        Gets the Key this provider supports.
        Returns:
        The key
      • allowsAsynchronousAccess

        boolean allowsAsynchronousAccess​(DataHolder dataHolder)
        Gets whether this provider will allow asynchronous access for retrieving and storing value changes through the API and implementation. This is usually sanity checked by the implementation through a simplified Engine.onMainThread() as a majority of datas are required to be synchronous if the changes can end up throwing ChangeDataHolderEvents.

        A list of methods that are constrained by this check are:

        Conceptually, an immutable DataHolder will be ignorant of asynchronous access, however, some cases may exist where attempting to create new immutable variants with different values can be still limited by synchronous access.
        Parameters:
        dataHolder - The data holder
        Returns:
        True if this provider allows asynchronous access
      • get

        java.util.Optional<E> get​(DataHolder dataHolder)
        Gets the elemental value from the provided DataHolder. This is generally considered the underlying implementation access for any ValueContainer.get(Key) where the Key is registered with this DataProvider. Nominally, this means the data is provided outside traditional serialized data that is stored with the DataHolder. It's possible that there may be changing return values for even immutable types, since the provider is providing the data.
        Parameters:
        dataHolder - The data holder
        Returns:
        The value, if it's supported and exists
      • value

        default java.util.Optional<V> value​(DataHolder dataHolder)
        Gets a constructed Value for the provided DataHolder. Much like get(DataHolder), this is generally considered the underlying implementation access for any ValueContainer.get(Key) where the Key is registered with this DataProvider. Nominally, this means the data is provided outside traditional serialized data that is stored with the DataHolder. It's possible that there may be changing return values for even immutable types, since the provider is providing the data.
        Parameters:
        dataHolder - The data holder to get the constructed value from
        Returns:
        The value
      • isSupported

        boolean isSupported​(DataHolder dataHolder)
        Gets whether this value provider is supported by the given ValueContainer.
        Parameters:
        dataHolder - The data holder
        Returns:
        Whether it's supported
      • isSupported

        default boolean isSupported​(io.leangen.geantyref.TypeToken<? extends DataHolder> dataHolder)
      • isSupported

        boolean isSupported​(java.lang.reflect.Type dataHolder)
      • withValue

        default <I extends DataHolder.Immutable<I>> java.util.Optional<I> withValue​(I immutable,
                                                                                    V value)
      • without

        <I extends DataHolder.Immutable<I>> java.util.Optional<I> without​(I immutable)
        Gets a DataHolder.Immutable without a Value with the target Key, if successful.
        Type Parameters:
        I - The type of the immutable value store
        Parameters:
        immutable - The immutable value store
        Returns:
        The new value store, if successful