Package org.spongepowered.api.data
Interface DataRegistration.Builder
-
- All Superinterfaces:
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 newDataRegistration
s. 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 DataRegistration
build()
DataRegistration.Builder
dataKey(Iterable<Key<?>> keys)
Gives theKey
to this builder signifying the key is to be registered either with an applicableDataProvider
or an associatedDataStore
that will provide serialization/deserialization behaviors.DataRegistration.Builder
dataKey(Key<?> key)
Gives theKey
to this builder signifying the key is to be registered either with an applicableDataProvider
or an associatedDataStore
that will provide serialization/deserialization behaviors.DataRegistration.Builder
dataKey(Key<?> key, Key<?>... others)
Gives theKey
to this builder signifying the key is to be registered either with an applicableDataProvider
or an associatedDataStore
that will provide serialization/deserialization behaviors.DataRegistration.Builder
provider(DataProvider<?,?> provider)
Gives the builder aDataProvider
of which is registered for a particularKey
.DataRegistration.Builder
reset()
Resets this builder to a "default" state such that there is no remaining data to set.DataRegistration.Builder
store(DataStore store)
Gives the builder aDataStore
that will enable supporting serializing and de-serializingValue
s given a context of a specificDataHolder
byTypeToken
.
-
-
-
Method Detail
-
store
DataRegistration.Builder store(DataStore store) throws DuplicateDataStoreException
Gives the builder aDataStore
that will enable supporting serializing and de-serializingValue
s given a context of a specificDataHolder
byTypeToken
. It is recommended that if theKey
s are meant to be all grouped/controlled together, a singleDataStore
is to serialize/de-serialize any and allValues
for 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 aDataProvider
of which is registered for a particularKey
. If aDataProvider
already exists for theKey
, aDuplicateProviderException
can be thrown.Note that by supplying a
DataProvider
, theValues
with the provider'sKey
will NOT be passed to any potentially registeredDataStores
for serialization. AKey
that has aDataProvider
will 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 theKey
to this builder signifying the key is to be registered either with an applicableDataProvider
or an associatedDataStore
that will provide serialization/deserialization behaviors. AKey
alone in the registration will allow for the understanding that theKey's
Value
will be constructed/provided for for variousDataHolder
s either through aDataProvider
dynamically, 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 theKey
to this builder signifying the key is to be registered either with an applicableDataProvider
or an associatedDataStore
that will provide serialization/deserialization behaviors. AKey
alone in the registration will allow for the understanding that theKey's
Value
will be constructed/provided for for variousDataHolder
s either through aDataProvider
dynamically, 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 theKey
to this builder signifying the key is to be registered either with an applicableDataProvider
or an associatedDataStore
that will provide serialization/deserialization behaviors. AKey
alone in the registration will allow for the understanding that theKey's
Value
will be constructed/provided for for variousDataHolder
s either through aDataProvider
dynamically, 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:Builder
Resets 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:
reset
in interfaceBuilder<DataRegistration,DataRegistration.Builder>
- Specified by:
reset
in interfaceResettableBuilder<DataRegistration,DataRegistration.Builder>
- Returns:
- This builder, for chaining
-
build
DataRegistration build()
- Specified by:
build
in interfaceBuildable.Builder<DataRegistration>
- Returns:
- The data registration object
- Throws:
IllegalStateException
- If registrations can no longer take placeIllegalStateException
- If there are noKey
s registered in this registrationIllegalStateException
- If there are noDataProvider
s orDataStore
s, resulting in the keys being dynamicDataAlreadyRegisteredException
- If a key has already been claimed by another registration
-
-