Package org.spongepowered.api.data
Interface DataRegistration.Builder
- All Superinterfaces:
AbstractBuilder<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 new
DataRegistrations. It's
always advised to create a new builder with
DataRegistration.builder() and calling reset() when
re-using said builder.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors.Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors.Gives theKeyto this builder signifying the key is to be registered either with an applicableDataProvideror an associatedDataStorethat will provide serialization/deserialization behaviors.provider(DataProvider<?, ?> provider) Gives the builder aDataProviderof which is registered for a particularKey.reset()Resets this builder to a "default" state such that there is no remaining data to set.Gives the builder aDataStorethat will enable supporting serializing and de-serializingValues given a context of a specificDataHolderbyTypeToken.
-
Method Details
-
store
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
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
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
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
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>- 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 dynamic
-