Package org.spongepowered.api.data
Interface DataRegistration.Builder
-
- All Superinterfaces:
AbstractBuilder<DataRegistration>,Buildable.Builder<DataRegistration>,Builder<DataRegistration,DataRegistration.Builder>,ResettableBuilder<DataRegistration,DataRegistration.Builder>
- Enclosing interface:
- DataRegistration
public static interface DataRegistration.Builder extends Builder<DataRegistration,DataRegistration.Builder>
A standard builder for constructing newDataRegistrations. It's always advised to create a new builder withDataRegistration.builder()and callingreset()when re-using said builder.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DataRegistrationbuild()DataRegistration.BuilderdataKey(Iterable<Key<?>> keys)Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors.DataRegistration.BuilderdataKey(Key<?> key)Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors.DataRegistration.BuilderdataKey(Key<?> key, Key<?>... others)Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors.DataRegistration.Builderprovider(DataProvider<?,?> provider)Gives the builder aDataProviderof which is registered for a particularKey.DataRegistration.Builderreset()Resets this builder to a "default" state such that there is no remaining data to set.DataRegistration.Builderstore(DataStore store)Gives the builder aDataStorethat will enable supporting serializing and de-serializingValues given a context of a specificDataHolderbyTypeToken.
-
-
-
Method Detail
-
store
DataRegistration.Builder store(DataStore store) throws DuplicateDataStoreException
Gives the builder aDataStorethat will enable supporting serializing and de-serializingValues given a context of a specificDataHolderbyTypeToken. It is recommended that if theKeys are meant to be all grouped/controlled together, a singleDataStoreis to serialize/de-serialize any and allValuesfor thoseKeys.- Parameters:
store- The data store providing the serialization process- Returns:
- This builder, for chaining
- Throws:
DuplicateDataStoreException- If the DataStore is already registered for the type token it uses
-
provider
DataRegistration.Builder provider(DataProvider<?,?> provider) throws DuplicateProviderException
Gives the builder aDataProviderof which is registered for a particularKey. If aDataProvideralready exists for theKey, aDuplicateProviderExceptioncan be thrown.Note that by supplying a
DataProvider, theValueswith the provider'sKeywill NOT be passed to any potentially registeredDataStoresfor serialization. AKeythat has aDataProviderwill always pass through thatDataProvider, and never aDataStore.- Parameters:
provider- The provider- Returns:
- This builder, for chaining
- Throws:
DuplicateProviderException- If there is already a DataProvider for the key
-
dataKey
DataRegistration.Builder dataKey(Key<?> key)
Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors. AKeyalone in the registration will allow for the understanding that theKey'sValuewill be constructed/provided for for variousDataHolders either through aDataProviderdynamically, or by a serialization strategy bya contextualized DataStore.- Parameters:
key- The key to register- Returns:
- This builder, for chaining
-
dataKey
DataRegistration.Builder dataKey(Key<?> key, Key<?>... others)
Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors. AKeyalone in the registration will allow for the understanding that theKey'sValuewill be constructed/provided for for variousDataHolders either through aDataProviderdynamically, or by a serialization strategy bya contextualized DataStore.- Parameters:
key- The key to registerothers- The additional keys- Returns:
- This builder, for chaining
-
dataKey
DataRegistration.Builder dataKey(Iterable<Key<?>> keys)
Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors. AKeyalone in the registration will allow for the understanding that theKey'sValuewill be constructed/provided for for variousDataHolders either through aDataProviderdynamically, or by a serialization strategy bya contextualized DataStore.- Parameters:
keys- The key to register- Returns:
- This builder, for chaining
-
reset
DataRegistration.Builder reset()
Description copied from interface:BuilderResets this builder to a "default" state such that there is no remaining data to set. This is to be the presumed "default" state.- Specified by:
resetin interfaceBuilder<DataRegistration,DataRegistration.Builder>- Specified by:
resetin interfaceResettableBuilder<DataRegistration,DataRegistration.Builder>- Returns:
- This builder, for chaining
-
build
DataRegistration build()
- Specified by:
buildin interfaceAbstractBuilder<DataRegistration>- Specified by:
buildin interfaceBuildable.Builder<DataRegistration>- Returns:
- The data registration object
- Throws:
IllegalStateException- If registrations can no longer take placeIllegalStateException- If there are noKeys registered in this registrationIllegalStateException- If there are noDataProviders orDataStores, resulting in the keys being dynamicDataAlreadyRegisteredException- If a key has already been claimed by another registration
-
-