public class Transaction<T extends DataSerializable> extends Object implements DataSerializable
Constructor and Description |
---|
Transaction(T original,
T defaultReplacement)
Creates a new transaction.
|
Transaction(T original,
T defaultReplacement,
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 . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
int |
getContentVersion()
Gets the content version of this
DataSerializable . |
Optional<T> |
getCustom()
Gets the custom snapshot if one was set.
|
T |
getDefault()
Gets the default replacement snapshot.
|
T |
getFinal()
Gets the proposed final snapshot, if the
getCustom() returns
Optional.isPresent() , the custom is returned, otherwise,
getDefault() is returned. |
List<? extends T> |
getIntermediary()
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. |
T |
getOriginal()
Gets the original snapshot.
|
int |
hashCode() |
boolean |
isValid()
Gets whether this transaction is marked as valid.
|
void |
setCustom(T custom)
Sets the custom snapshot.
|
void |
setValid(boolean valid)
Sets whether this transaction is valid or not.
|
DataContainer |
toContainer()
Serializes this object into a comprehensible
DataContainer . |
String |
toString() |
public Transaction(T original, T defaultReplacement)
original
- The original object being replaceddefaultReplacement
- The default replacementpublic Transaction(T original, T defaultReplacement, @Nullable List<? extends T> intermediary)
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
- defaultReplacement
- intermediary
- public final T getOriginal()
public final T getDefault()
public final List<? extends T> getIntermediary()
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
.
public final Optional<T> getCustom()
public final void setCustom(@Nullable T custom)
null
, this will
reset to use the getDefault()
snapshot.custom
- The custom snapshotpublic final T getFinal()
getCustom()
returns
Optional.isPresent()
, the custom is returned, otherwise,
getDefault()
is returned.public final boolean isValid()
public final void setValid(boolean valid)
valid
- The valid state of this transactionpublic int getContentVersion()
DataSerializable
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.getContentVersion
in interface DataSerializable
public DataContainer toContainer()
DataSerializable
DataContainer
.toContainer
in interface DataSerializable