Class Transaction<T extends DataSerializable>

    • Constructor Detail

      • Transaction

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

        public Transaction​(T original,
                           T defaultReplacement,
                           @Nullable java.util.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.

        Parameters:
        original - The original
        defaultReplacement - The replacement
        intermediary - The intermediary results
    • Method Detail

      • original

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

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

        public final java.util.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.

        Returns:
        The intermediary list of transactions
      • custom

        public final java.util.Optional<T> custom()
        Gets the custom snapshot if one was set.
        Returns:
        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.
        Parameters:
        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.
        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()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(@Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object