Package org.spongepowered.api.data
Class Transaction<T extends DataSerializable>
java.lang.Object
org.spongepowered.api.data.Transaction<T>
- All Implemented Interfaces:
DataSerializable
- Direct Known Subclasses:
BlockTransaction,SlotTransaction
-
Constructor Summary
ConstructorsConstructorDescriptionTransaction(T original, T defaultReplacement) Creates a new transaction.Transaction(T original, T defaultReplacement, @Nullable List<? extends T> intermediary) Creates a newTransactionwith the added possibility of intermediary transactions that may have taken place between what isoriginalandthe default result. -
Method Summary
Modifier and TypeMethodDescriptionintGets the content version of thisDataSerializable.custom()Gets the custom snapshot if one was set.final TGets the default replacement snapshot.booleanfinal TGets the proposed final snapshot, if thecustom()returnsOptional.isPresent(), the custom is returned, otherwise,defaultReplacement()is returned.inthashCode()Gets aListof any and all intermediary transactions that may have taken place to get the finalTransactionofthe originalandthe defaultresults.final voidfinal booleanisValid()Gets whether this transaction is marked as valid.final Toriginal()Gets the original snapshot.final voidSets the custom snapshot.final voidsetValid(boolean valid) Sets whether this transaction is valid or not.Serializes this object into a comprehensibleDataContainer.toString()final voidvalidate()
-
Constructor Details
-
Transaction
Creates a new transaction.- Parameters:
original- The original object being replaceddefaultReplacement- The default replacement
-
Transaction
Creates a newTransactionwith the added possibility of intermediary transactions that may have taken place between what isoriginalandthe default result. The list may benull, however the list will wrapped to become an unmodifiable list.It is imperative that the provided list is not to be modified outside this created
Transactionsynchronously and asynchronously as consumers of the provided list will not be able to react accordingly.- Parameters:
original- The originaldefaultReplacement- The replacementintermediary- The intermediary results
-
-
Method Details
-
original
Gets the original snapshot.- Returns:
- The original snapshot
-
defaultReplacement
Gets the default replacement snapshot.- Returns:
- The default replacement
-
intermediary
Gets aListof any and all intermediary transactions that may have taken place to get the finalTransactionofthe originalandthe defaultresults. This is exposed for monitoring purposes only, as the provided list is not modifiable. The list may beemptyby default, but will never benull.Note that special processing with this list may sometimes only take place if
a customresult has not been set by a plugin, or ifisValid()returnsfalse.- Returns:
- The intermediary list of transactions
-
custom
Gets the custom snapshot if one was set.- Returns:
- The custom snapshot, if available
-
setCustom
Sets the custom snapshot. If settingnull, this will reset to use thedefaultReplacement()snapshot.- Parameters:
custom- The custom snapshot
-
finalReplacement
Gets the proposed final snapshot, if thecustom()returnsOptional.isPresent(), the custom is returned, otherwise,defaultReplacement()is returned.- Returns:
- The proposed final snapshot
-
isValid
public final boolean isValid()Gets whether this transaction is marked as valid.- Returns:
- The valid state of this transaction
-
setValid
public final void setValid(boolean valid) Sets whether this transaction is valid or not.- Parameters:
valid- The valid state of this transaction
-
validate
public final void validate() -
invalidate
public final void invalidate() -
hashCode
public int hashCode() -
equals
-
toString
-
contentVersion
public int contentVersion()Description copied from interface:DataSerializableGets the content version of thisDataSerializable. The version may differ between instances of plugins and implementations such that theDataViewfromDataSerializable.toContainer()may include different information, or remove other information as they are no longer deemed necessary. The version goes hand in hand withDataContentUpdateras it is required when there exists anyDataViewof thisDataSerializablewith an "older" version.- Specified by:
contentVersionin interfaceDataSerializable- Returns:
- The version of the content being serialized
-
toContainer
Description copied from interface:DataSerializableSerializes this object into a comprehensibleDataContainer.- Specified by:
toContainerin interfaceDataSerializable- Returns:
- A newly created DataContainer
-