public final class DataTransactionResult extends Object
DataHolder
is
accepting DataManipulator
s.Modifier and Type | Class and Description |
---|---|
static class |
DataTransactionResult.Builder
A type of builder for building
DataTransactionResult s. |
static class |
DataTransactionResult.Type
The type of transaction result.
|
Modifier and Type | Method and Description |
---|---|
static DataTransactionResult.Builder |
builder()
Gets a new
DataTransactionResult.Builder to build a new
DataTransactionResult . |
boolean |
equals(Object o) |
static DataTransactionResult |
errorResult(ImmutableValue<?> value)
Creates a new
DataTransactionResult that ends in failure. |
static DataTransactionResult |
failNoData()
Creates a new
DataTransactionResult that ends in failure. |
static DataTransactionResult |
failResult(ImmutableValue<?> value)
Creates a new
DataTransactionResult that ends in failure. |
static DataTransactionResult |
failResult(Iterable<ImmutableValue<?>> values)
Creates a new
DataTransactionResult that ends in failure. |
List<ImmutableValue<?>> |
getRejectedData()
If
Value s were supplied to the operation, this
collection will return any ImmutableValue s which were rejected
by the target DataHolder . |
List<ImmutableValue<?>> |
getReplacedData()
If the operation replaced any
Value s, this returns a collection
of the replaced ImmutableValue s. |
List<ImmutableValue<?>> |
getSuccessfulData()
If any
BaseValue s applied onto a CompositeValueStore were
successful, they'll be stored in the given list. |
DataTransactionResult.Type |
getType()
Gets the type of result.
|
int |
hashCode() |
<E extends Exception> |
ifNotSuccessful(Supplier<E> supplier)
Used to call a
Supplier for an Exception of type
E such that if this transaction's isSuccessful()
returns false , the supplier's exception is thrown. |
void |
ifSuccessful(Consumer<List<ImmutableValue<?>>> consumer)
If this result of
isSuccessful() returns true ,
the provided Consumer is called provided a list of all
"successful" data as retrieved from getSuccessfulData() . |
void |
ifSucessful(Consumer<List<ImmutableValue<?>>> consumer)
Deprecated.
Use
ifSuccessful(Consumer) instead |
boolean |
isSuccessful()
Gets whether this
DataTransactionResult was successful or not. |
static DataTransactionResult |
successNoData()
Creates a
DataTransactionResult with no data successfully added,
removed, or rejected, and with the
DataTransactionResult.Type of
DataTransactionResult.Type.SUCCESS
result type. |
static DataTransactionResult |
successRemove(Collection<ImmutableValue<?>> removed)
Creates a
DataTransactionResult with the provided
ImmutableValue s being successfully removed. |
static DataTransactionResult |
successRemove(ImmutableValue<?> removed)
Creates a
DataTransactionResult with the provided
ImmutableValue being successfully removed. |
static DataTransactionResult |
successReplaceResult(Collection<ImmutableValue<?>> successful,
Collection<ImmutableValue<?>> replaced)
Creates a new
DataTransactionResult with the provided
ImmutableValue s being the successful additions and
the provided ImmutableValue s that were replaced. |
static DataTransactionResult |
successReplaceResult(ImmutableValue<?> successful,
ImmutableValue<?> replaced)
Creates a new
DataTransactionResult with the provided
ImmutableValue being the successful addition. |
static DataTransactionResult |
successResult(ImmutableValue<?> value)
Creates a new
DataTransactionResult with the provided
ImmutableValue being the successful addition. |
String |
toString() |
public static DataTransactionResult.Builder builder()
DataTransactionResult.Builder
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 successRemove(Collection<ImmutableValue<?>> removed)
DataTransactionResult
with the provided
ImmutableValue
s being successfully removed. 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.removed
- The successfully removed valuespublic static DataTransactionResult successRemove(ImmutableValue<?> removed)
DataTransactionResult
with the provided
ImmutableValue
being successfully removed. 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 a
BaseValue
should be provided as an ImmutableValue
or
transformed into an ImmutableValue
.removed
- The successfully removed valuepublic 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(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 DataTransactionResult.Type getType()
public boolean isSuccessful()
DataTransactionResult
was successful or not.public List<ImmutableValue<?>> getSuccessfulData()
BaseValue
s applied onto a CompositeValueStore
were
successful, they'll be stored in the given list.public List<ImmutableValue<?>> getRejectedData()
Value
s were supplied to the operation, this
collection will return any ImmutableValue
s which were rejected
by the target DataHolder
.public List<ImmutableValue<?>> getReplacedData()
Value
s, this returns a collection
of the replaced ImmutableValue
s.public void ifSuccessful(Consumer<List<ImmutableValue<?>>> consumer)
isSuccessful()
returns true
,
the provided Consumer
is called provided a list of all
"successful" data as retrieved from getSuccessfulData()
.consumer
- The consumer to call@Deprecated public void ifSucessful(Consumer<List<ImmutableValue<?>>> consumer)
ifSuccessful(Consumer)
insteadisSuccessful()
returns true
,
the provided Consumer
is called provided a list of all
"successful" data as retrieved from getSuccessfulData()
.consumer
- The consumer to callpublic <E extends Exception> void ifNotSuccessful(Supplier<E> supplier) throws E extends Exception
Supplier
for an Exception
of type
E
such that if this transaction's isSuccessful()
returns false
, the supplier's exception is thrown.E
- The type of exceptionsupplier
- The supplier of the exception to throwE
- The exception to throw if this transaction is not successfulE extends Exception