Package org.spongepowered.api.data
Interface DataManager
public interface DataManager
A manager of the overall Data API. This handles the registration of
 
DataSerializables and their DataBuilders,
 DataRegistrations, etc.
 Note that this manager powers not just serialization and deserialization, but also powers a majority of the Data API.
- 
Method SummaryModifier and TypeMethodDescription<T extends DataSerializable>
 Optional<DataBuilder<T>>Attempts to retrieve theDataBuilderfor the desiredDataSerializableclass.Creates a newDataContainerwith a defaultDataView.SafetyModeofDataView.SafetyMode.ALL_DATA_CLONED.createContainer(DataView.SafetyMode safety) Creates a newDataContainerwith the providedDataView.SafetyMode.<T extends DataSerializable>
 Optional<T>deserialize(Class<T> clazz, DataView dataView) Attempts to translate an instance of theDataSerializablefrom the providedDataView.<T extends DataHolder.Immutable<T>,B extends DataHolderBuilder.Immutable<T, B>> 
 Optional<B>immutableBuilder(Class<T> holderClass) Attempts to retrieve the builder for the givenDataHolder.Immutable.<T extends DataHolder.Immutable<T>,B extends DataHolderBuilder.Immutable<T, B>> 
 voidRegisters the givenDataHolder.Immutableclass with it's associatedDataHolderBuilder.Immutable.<T extends DataSerializable>
 voidregisterBuilder(Class<T> clazz, DataBuilder<T> builder) Registers aDataBuilderthat will dynamically build the givenDataSerializablefrom aDataContainer.<T extends DataSerializable>
 voidregisterContentUpdater(Class<T> clazz, DataContentUpdater updater) Registers aDataContentUpdaterfor the desiredDataSerializablesuch that any versioned data may be updated to newer versions for the most up to dateDataBuilder.voidregisterLegacyManipulatorIds(String legacyId, ResourceKey dataStoreKey) Registers a legacyidthat is used by a previous version ofDataRegistrationfrom a plugin such that the custom data can be read by a plugin-data datastore.<T> Optional<DataTranslator<T>>translator(Class<T> objectClass) Gets the desiredDataTranslatorfor the provided class.<T extends DataSerializable>
 Optional<DataContentUpdater>wrappedContentUpdater(Class<T> clazz, int fromVersion, int toVersion) Gets a wrapped fakeDataContentUpdaterthat may wrap severalDataContentUpdaters to translate versioned data from the desiredfromVersionto thetoVersion.
- 
Method Details- 
registerBuilderRegisters aDataBuilderthat will dynamically build the givenDataSerializablefrom aDataContainer.Builders may not always exist for a given DataSerializable, nor is it guaranteed that a provided builder will function with allDataContainers.- Type Parameters:
- T- The type of data serializable
- Parameters:
- clazz- The class of the- DataSerializable
- builder- The builder that can build the data serializable
 
- 
registerContentUpdater<T extends DataSerializable> void registerContentUpdater(Class<T> clazz, DataContentUpdater updater) Registers aDataContentUpdaterfor the desiredDataSerializablesuch that any versioned data may be updated to newer versions for the most up to dateDataBuilder.- Type Parameters:
- T- The type of DataSerializable
- Parameters:
- clazz- The data serializable class
- updater- The updater
 
- 
wrappedContentUpdater<T extends DataSerializable> Optional<DataContentUpdater> wrappedContentUpdater(Class<T> clazz, int fromVersion, int toVersion) Gets a wrapped fakeDataContentUpdaterthat may wrap severalDataContentUpdaters to translate versioned data from the desiredfromVersionto thetoVersion. If the version jump is too great or aDataContentUpdaterhas not been registered to cover the complete jump,Optional.empty()may be returned.- Type Parameters:
- T- The type of data serializable
- Parameters:
- clazz- The data serializable class
- fromVersion- The version converting from
- toVersion- The version converting to
- Returns:
- The content updater, if available
 
- 
builderAttempts to retrieve theDataBuilderfor the desiredDataSerializableclass.Builders may not always exist for a given DataSerializable, nor is it guaranteed that a provided builder will function with allDataContainers.- Type Parameters:
- T- The type of data serializable
- Parameters:
- clazz- The class of the data serializable
- Returns:
- The builder, if available
 
- 
deserializeAttempts to translate an instance of theDataSerializablefrom the providedDataView. If there is noDataBuilderregistered for the providedDataSerializable, thenOptional.empty()may be returned.- Type Parameters:
- T- The type of data serializable
- Parameters:
- clazz- The class of the data serializable
- dataView- The data view containing raw data
- Returns:
- The data serializable, if available
 
- 
register<T extends DataHolder.Immutable<T>,B extends DataHolderBuilder.Immutable<T, void registerB>> (Class<T> holderClass, B builder) Registers the givenDataHolder.Immutableclass with it's associatedDataHolderBuilder.Immutable. The builder can be used to create new instances of the givenDataHolder.Immutablefor data retrieval, data representation, etc.- Type Parameters:
- T- The type of immutable data holder
- B- The type of immutable data builder
- Parameters:
- holderClass- The class of the immutable data holder
- builder- The builder instance of the immutable data holder
 
- 
registerLegacyManipulatorIdsRegisters a legacyidthat is used by a previous version ofDataRegistrationfrom a plugin such that the custom data can be read by a plugin-data datastore.- Parameters:
- legacyId- The legacy id
- dataStoreKey- The dataStore key set in- DataStore.Builder.pluginData(ResourceKey)
 
- 
immutableBuilder<T extends DataHolder.Immutable<T>,B extends DataHolderBuilder.Immutable<T, Optional<B> immutableBuilderB>> (Class<T> holderClass) Attempts to retrieve the builder for the givenDataHolder.Immutable.If the DataHolder.Immutablewas not registered, multiple systems could fail to retrieve specific data.- Type Parameters:
- T- The type of immutable data holder
- B- The type of immutable data builder
- Parameters:
- holderClass- The immutable data holder class
- Returns:
- The builder, if available
 
- 
translatorGets the desiredDataTranslatorfor the provided class.- Type Parameters:
- T- The type of object
- Parameters:
- objectClass- The class of the object
- Returns:
- The data translator, if available
 
- 
createContainerDataContainer createContainer()Creates a newDataContainerwith a defaultDataView.SafetyModeofDataView.SafetyMode.ALL_DATA_CLONED.- Returns:
- A new data container
 
- 
createContainerCreates a newDataContainerwith the providedDataView.SafetyMode.- Parameters:
- safety- The safety mode to use
- Returns:
- A new data container with the provided safety mode
- See Also:
 
 
-