Interface DataRegistration


public interface DataRegistration
An optional registration of keys to associate a semi-persistent state of their associated values that can be stored, retrieved, persisted, and/or associated with DataHolders. A registration identifies the given Keys are provided by an implementation for specific DataHolders that may support and not support those keys. All API provided keys exposed through the Keys class will have an associated registration by the implementation of the API, whether they are usable through DataProviders or DataStores.

If dynamic or persistent retention of the Values by keys is not desired, a registration is optional. This would mean that any submitted Values of a Key without an associated DataRegistration will be only stored on a mutable DataHolder for the duration that that holder exists. The value would not persist between reloads, restarts, etc.

  • Method Details

    • builder

      static DataRegistration.Builder builder()
      Creates a new DataRegistration.Builder to build a DataRegistration. Through the use of generics, this can be duck-typed to the generics of the desired DataManipulator type to be registered.
      Returns:
      The new builder instance
    • providersFor

      <V extends Value<E>, E> Collection<DataProvider<V,E>> providersFor(Key<V> key) throws UnregisteredKeyException
      Gets the DataProvider for the given Key to potentially get or offer Values from any ValueContainer provided that the container is supported by the DataProvider. If the key is not actually registered with this DataRegistration, an UnregisteredKeyException is thrown. If there is no DataProvider registered for the particular Key, Optional.empty() is returned.
      Type Parameters:
      V - The value type
      E - The element type
      Parameters:
      key - The requested key
      Returns:
      The provider, if there is one for the key
      Throws:
      UnregisteredKeyException - If the key is not registered in this registration
    • dataStore

      Optional<DataStore> dataStore(io.leangen.geantyref.TypeToken<? extends DataHolder> token)
      Gets the appropriate DataStore for the context of the TypeToken that is being serialized/deserialized. It is always possible that there may be a DataStore that does not support the provided TypeToken, while a DataProvider may be provided for a particular Key.
      Parameters:
      token - The type token of the desired ValueContainer
      Returns:
      The relevant DataStore for the desired type token of the target type.
    • dataStore

      Optional<DataStore> dataStore(Class<? extends DataHolder> token)
      Gets the appropriate DataStore for the context of the TypeToken that is being serialized/deserialized. It is always possible that there may be a DataStore that does not support the provided Class, while a DataProvider may be provided for a particular Key.
      Parameters:
      token - The class of the desired ValueContainer. Cannot be a raw type
      Returns:
      The relevant DataStore for the desired type token of the target type.
    • keys

      Iterable<Key<?>> keys()
      Gets the registered Keys this controls. Note that each Key can only be registered/owned by a single PluginContainer. It is possible for there to be only a single key registered, or multiple, depending on the basis of what potentially grouped values are controlled by a single DataStore or multiple DataProviders, based on the supported DataHolders.
      Returns:
      The keys registered
    • of

      @SafeVarargs static <T, V extends Value<T>> DataRegistration of(Key<V> key, Class<? extends DataHolder> dataHolder, Class<? extends DataHolder>... dataHolders)
      Creates a DataRegistration for a single key with a DataStore for given data-holders.
      Type Parameters:
      T - the value's type
      V - the value type
      Parameters:
      key - the data key
      dataHolders - the data-holders
      Returns:
      The built data registration