public final class DataTransactionBuilder extends Object
DataTransactionResult
s. The common
use is for both implementations of DataHolder
s, and various
ChangeDataHolderEvent.ValueChange
s.public static DataTransactionBuilder builder()
DataTransactionBuilder
to build a new
DataTransactionResult
.public static DataTransactionResult successNoData()
DataTransactionResult
with no data successfully added,
removed, or rejected, and with the
DataTransactionResult.Type
of
DataTransactionResult.Type.SUCCESS
result type.public static DataTransactionResult successResult(ImmutableValue<?> value)
DataTransactionResult
with the provided
ImmutableValue
being the successful addition. The result type is
still DataTransactionResult.Type.SUCCESS
. If a Value
is
necessary, use Value.asImmutable()
to use this method. A
DataTransactionResult
is always immutable once created, and any
BaseValue
s should be provided as ImmutableValue
s or
transformed into ImmutableValue
s.value
- The successfully added immutable valuepublic static DataTransactionResult successReplaceResult(ImmutableValue<?> successful, ImmutableValue<?> replaced)
DataTransactionResult
with the provided
ImmutableValue
being the successful addition. The result type is
still DataTransactionResult.Type.SUCCESS
. If a Value
is
necessary, use Value.asImmutable()
to use this method. A
DataTransactionResult
is always immutable once created, and any
BaseValue
s should be provided as ImmutableValue
s or
transformed into ImmutableValue
s.successful
- The successfully added immutable valuereplaced
- The replaced valuepublic static DataTransactionResult successReplaceResult(Collection<ImmutableValue<?>> successful, Collection<ImmutableValue<?>> replaced)
DataTransactionResult
with the provided
ImmutableValue
s being the successful additions and
the provided ImmutableValue
s that were replaced. The result type
is still DataTransactionResult.Type.SUCCESS
. If a Value
is necessary, use Value.asImmutable()
to use this method. A
DataTransactionResult
is always immutable once created, and any
BaseValue
s should be provided as ImmutableValue
s or
transformed into ImmutableValue
s.successful
- The successfully added immutable valuesreplaced
- The successfully replaced immutable valuespublic static DataTransactionResult failResult(ImmutableValue<?> value)
DataTransactionResult
that ends in failure. The
provided ImmutableValue
is considered "rejected" and was not
successfully added.value
- The value that was rejectedpublic static DataTransactionResult failResult(ImmutableValue<?>... values)
DataTransactionResult
that ends in failure. The
provided ImmutableValue
s are considered "rejected" and were not
successfully added.values
- The values that were rejectedpublic static DataTransactionResult failResult(Iterable<ImmutableValue<?>> values)
DataTransactionResult
that ends in failure. The
provided ImmutableValue
s are considered "rejected" and were not
successfully added.values
- The values that were rejectedpublic static DataTransactionResult failNoData()
DataTransactionResult
that ends in failure. There
is no additional data to include.public static DataTransactionResult errorResult(ImmutableValue<?> value)
DataTransactionResult
that ends in failure. The
provided ImmutableValue
is considered "incompatible" and was not
successfully added.value
- The value that was incompatible or erroredpublic DataTransactionBuilder result(DataTransactionResult.Type type)
DataTransactionResult.Type
to the provided
type. A DataTransactionResult
must always have a type to mark
the transaction a "success" or "failure".type
- The type of the transaction resultpublic DataTransactionBuilder replace(ImmutableValue<?> value)
ImmutableValue
to the List
of
"replaced" ImmutableValue
s. The replaced values are always
copied for every DataTransactionResult
for referencing. It is
also possible ot retrieve these replaced ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.value
- The value to replacepublic DataTransactionBuilder replace(ImmutableValue<?> value, ImmutableValue<?>... values)
ImmutableValue
s to the List
of
"replaced" ImmutableValue
s. The replaced values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these replaced ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.values
- The values to replacepublic DataTransactionBuilder replace(Collection<ImmutableValue<?>> values)
ImmutableValue
s to the List
of
"replaced" ImmutableValue
s. The replaced values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these replaced ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.values
- The values to replacepublic DataTransactionBuilder reject(ImmutableValue<?> value)
ImmutableValue
to the List
of
"rejected" ImmutableValue
s. The rejected values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these rejected ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.value
- The values to rejectpublic DataTransactionBuilder reject(ImmutableValue<?>... values)
ImmutableValue
s to the List
of
"rejected" ImmutableValue
s. The rejected values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these rejected ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.values
- The values to rejectpublic DataTransactionBuilder reject(Iterable<ImmutableValue<?>> values)
ImmutableValue
s to the List
of
"rejected" ImmutableValue
s. The rejected values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these rejected ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.values
- The values to rejectpublic DataTransactionBuilder success(ImmutableValue<?> value)
ImmutableValue
to the List
of
"successful" ImmutableValue
s. The rejected values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these successful ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.value
- The value that was successfully providedpublic DataTransactionBuilder success(ImmutableValue<?>... values)
ImmutableValue
s to the List
of
"successful" ImmutableValue
s. The rejected values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these successful ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.values
- The values that were successfully providedpublic DataTransactionBuilder success(Iterable<ImmutableValue<?>> values)
ImmutableValue
s to the List
of
"successful" ImmutableValue
s. The rejected values are always
copied for every DataTransactionResult
for referencing. It is
also possible to retrieve these successful ImmutableValue
s to
CompositeValueStore.undo(DataTransactionResult)
at a later point in
the lifespan of the DataHolder
.values
- The values that were successfully providedpublic DataTransactionBuilder absorbResult(DataTransactionResult result)
DataTransactionResult
with the
one provided. Usually, this means that there is some merging of the
ImmutableValue
s based on Key
. If this builder already
has an ImmutableValue
as being successfully offered, and the
provided result shows the same key as being rejected, the rejected
ImmutableValue
will remain in the final result.result
- The result to mergepublic DataTransactionResult build()
DataTransactionResult
with the providing
List
s of ImmutableValue
s that are successfully
offered, ImmutableValue
s that were replaced, and
ImmutableValue
s that were rejected.