Package org.spongepowered.api.data
Interface DataProvider<V extends Value<E>,E>
- All Known Subinterfaces:
DirectionRelativeDataProvider<V,
E>
public interface DataProvider<V extends Value<E>,E>
-
Method Summary
Modifier and TypeMethodDescriptionboolean
allowsAsynchronousAccess
(DataHolder dataHolder) Gets whether this provider will allow asynchronous access for retrieving and storing value changes through the API and implementation.get
(DataHolder dataHolder) Gets the elemental value from the providedDataHolder
.static <H extends DataHolder,
V extends Value<E>, E>
ImmutableDataProviderBuilder<H,V, E> Constructs a newImmutableDataProviderBuilder
.default boolean
isSupported
(io.leangen.geantyref.TypeToken<? extends DataHolder> dataHolder) boolean
isSupported
(Type dataHolder) boolean
isSupported
(DataHolder dataHolder) Gets whether this value provider is supported by the givenValueContainer
.key()
Gets theKey
this provider supports.static <H extends DataHolder.Mutable,
V extends Value<E>, E>
MutableDataProviderBuilder<H,V, E> Constructs a newMutableDataProviderBuilder
.offer
(DataHolder.Mutable dataHolder, E element) default DataTransactionResult
offerValue
(DataHolder.Mutable dataHolder, V value) remove
(DataHolder.Mutable dataHolder) value
(DataHolder dataHolder) Gets a constructedValue
for the providedDataHolder
.<I extends DataHolder.Immutable<I>>
Optional<I><I extends DataHolder.Immutable<I>>
Optional<I>without
(I immutable) default <I extends DataHolder.Immutable<I>>
Optional<I>
-
Method Details
-
mutableBuilder
static <H extends DataHolder.Mutable,V extends Value<E>, MutableDataProviderBuilder<H,E> V, mutableBuilder()E> Constructs a newMutableDataProviderBuilder
.- Returns:
- The builder
-
immutableBuilder
static <H extends DataHolder,V extends Value<E>, ImmutableDataProviderBuilder<H,E> V, immutableBuilder()E> Constructs a newImmutableDataProviderBuilder
.- Returns:
- The builder
-
key
Gets theKey
this provider supports.- Returns:
- The key
-
allowsAsynchronousAccess
Gets whether this provider will allow asynchronous access for retrieving and storing value changes through the API and implementation. This is usually sanity checked by the implementation through a simplifiedEngine.onMainThread()
as a majority of datas are required to be synchronous if the changes can end up throwingChangeDataHolderEvent
s.A list of methods that are constrained by this check are:
Conceptually, an immutableDataHolder
will be ignorant of asynchronous access, however, some cases may exist where attempting to create new immutable variants with different values can be still limited by synchronous access.- Parameters:
dataHolder
- The data holder- Returns:
- True if this provider allows asynchronous access
-
get
Gets the elemental value from the providedDataHolder
. This is generally considered the underlying implementation access for anyValueContainer.get(Key)
where theKey
is registered with thisDataProvider
. Nominally, this means the data is provided outside traditional serialized data that is stored with theDataHolder
. It's possible that there may be changing return values for even immutable types, since the provider is providing the data.- Parameters:
dataHolder
- The data holder- Returns:
- The value, if it's supported and exists
-
value
Gets a constructedValue
for the providedDataHolder
. Much likeget(DataHolder)
, this is generally considered the underlying implementation access for anyValueContainer.get(Key)
where theKey
is registered with thisDataProvider
. Nominally, this means the data is provided outside traditional serialized data that is stored with theDataHolder
. It's possible that there may be changing return values for even immutable types, since the provider is providing the data.- Parameters:
dataHolder
- The data holder to get the constructed value from- Returns:
- The value
-
isSupported
Gets whether this value provider is supported by the givenValueContainer
.- Parameters:
dataHolder
- The data holder- Returns:
- Whether it's supported
-
isSupported
-
isSupported
-
offer
-
offerValue
-
remove
-
with
-
withValue
-
without
- Type Parameters:
I
- The type of the immutable value store- Parameters:
immutable
- The immutable value store- Returns:
- The new value store, if successful
-