Class Transaction<T extends DataSerializable>

All Implemented Interfaces:
Direct Known Subclasses:
BlockTransaction, SlotTransaction

public class Transaction<T extends DataSerializable> extends Object implements DataSerializable
  • Constructor Details

    • Transaction

      public Transaction(T original, T defaultReplacement)
      Creates a new transaction.
      original - The original object being replaced
      defaultReplacement - The default replacement
    • Transaction

      public Transaction(T original, T defaultReplacement, @Nullable List<? extends T> intermediary)
      Creates a new Transaction with the added possibility of intermediary transactions that may have taken place between what is original and the default result. The list may be null, 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 Transaction synchronously and asynchronously as consumers of the provided list will not be able to react accordingly.

      original - The original
      defaultReplacement - The replacement
      intermediary - The intermediary results
  • Method Details

    • original

      public final T original()
      Gets the original snapshot.
      The original snapshot
    • defaultReplacement

      public final T defaultReplacement()
      Gets the default replacement snapshot.
      The default replacement
    • intermediary

      public final List<? extends T> intermediary()
      Gets a List of any and all intermediary transactions that may have taken place to get the final Transaction of the original and the default results. This is exposed for monitoring purposes only, as the provided list is not modifiable. The list may be empty by default, but will never be null.

      Note that special processing with this list may sometimes only take place if a custom result has not been set by a plugin, or if isValid() returns false.

      The intermediary list of transactions
    • custom

      public final Optional<T> custom()
      Gets the custom snapshot if one was set.
      The custom snapshot, if available
    • setCustom

      public final void setCustom(@Nullable T custom)
      Sets the custom snapshot. If setting null, this will reset to use the defaultReplacement() snapshot.
      custom - The custom snapshot
    • finalReplacement

      public final T finalReplacement()
      Gets the proposed final snapshot, if the custom() returns Optional.isPresent(), the custom is returned, otherwise, defaultReplacement() is returned.
      The proposed final snapshot
    • isValid

      public final boolean isValid()
      Gets whether this transaction is marked as valid.
      The valid state of this transaction
    • setValid

      public final void setValid(boolean valid)
      Sets whether this transaction is valid or not.
      valid - The valid state of this transaction
    • validate

      public final void validate()
    • invalidate

      public final void invalidate()
    • hashCode

      public int hashCode()
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      equals in class Object
    • toString

      public String toString()
      toString in class Object
    • contentVersion

      public int contentVersion()
      Description copied from interface: DataSerializable
      Gets the content version of this DataSerializable. The version may differ between instances of plugins and implementations such that the DataView from DataSerializable.toContainer() may include different information, or remove other information as they are no longer deemed necessary. The version goes hand in hand with DataContentUpdater as it is required when there exists any DataView of this DataSerializable with an "older" version.
      Specified by:
      contentVersion in interface DataSerializable
      The version of the content being serialized
    • toContainer

      public DataContainer toContainer()
      Description copied from interface: DataSerializable
      Serializes this object into a comprehensible DataContainer.
      Specified by:
      toContainer in interface DataSerializable
      A newly created DataContainer