Class Transaction<T extends DataSerializable>

    • Constructor Detail

      • 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 Detail

      • 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
      • 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