Package org.spongepowered.api.data
Class DataTransactionResult.Builder
java.lang.Object
org.spongepowered.api.data.DataTransactionResult.Builder
- All Implemented Interfaces:
AbstractBuilder<DataTransactionResult>
,Builder<DataTransactionResult,
,DataTransactionResult.Builder> CopyableBuilder<DataTransactionResult,
,DataTransactionResult.Builder> ResettableBuilder<DataTransactionResult,
DataTransactionResult.Builder>
- Enclosing class:
- DataTransactionResult
public static final class DataTransactionResult.Builder
extends Object
implements Builder<DataTransactionResult,DataTransactionResult.Builder>, CopyableBuilder<DataTransactionResult,DataTransactionResult.Builder>
A type of builder for building
DataTransactionResult
s. The common
use is for both implementations of DataHolder
s, and various
ChangeDataHolderEvent.ValueChange
s.-
Method Summary
Modifier and TypeMethodDescriptionabsorbResult
(DataTransactionResult result) Combines the currently buildingDataTransactionResult
with the one provided.build()
Builds a newDataTransactionResult
with the providingList
s ofValue.Immutable
s that are successfully offered,Value.Immutable
s that were replaced, andValue.Immutable
s that were rejected.from
(DataTransactionResult value) Resets this builder to the values of the given built object.reject
(Iterable<Value.Immutable<?>> values) reject
(Value.Immutable<?> value) replace
(Iterable<Value.Immutable<?>> values) replace
(Value.Immutable<?> value) reset()
Resets this builder to a "default" state such that there is no remaining data to set.Sets the expectantDataTransactionResult.Type
to the provided type.success
(Iterable<Value.Immutable<?>> values) success
(Value.Immutable<?> value)
-
Method Details
-
result
Sets the expectantDataTransactionResult.Type
to the provided type. ADataTransactionResult
must always have a type to mark the transaction a "success" or "failure".- Parameters:
type
- The type of the transaction result- Returns:
- This builder, for chaining
-
replace
Adds the providedValue.Immutable
to theList
of "replaced"Value.Immutable
s. The replaced values are always copied for everyDataTransactionResult
for referencing.- Parameters:
value
- The value to replace- Returns:
- This builder, for chaining
-
replace
Adds the providedValue.Immutable
s to theList
of "replaced"Value.Immutable
s. The replaced values are always copied for everyDataTransactionResult
for referencing.- Parameters:
values
- The values to replace- Returns:
- This builder, for chaining
-
reject
Adds the providedValue.Immutable
to theList
of "rejected"Value.Immutable
s. The rejected values are always copied for everyDataTransactionResult
for referencing.- Parameters:
value
- The values to reject- Returns:
- This builder, for chaining
-
reject
Adds the providedValue.Immutable
s to theList
of "rejected"Value.Immutable
s. The rejected values are always copied for everyDataTransactionResult
for referencing.- Parameters:
values
- The values to reject- Returns:
- This builder, for chaining
-
success
Adds the providedValue.Immutable
to theList
of "successful"Value.Immutable
s. The successful values are always copied for everyDataTransactionResult
for referencing.- Parameters:
value
- The value that was successfully provided- Returns:
- This builder, for chaining
-
success
Adds the providedValue.Immutable
s to theList
of "successful"Value.Immutable
s. The rejected values are always copied for everyDataTransactionResult
for referencing.- Parameters:
values
- The values that were successfully provided- Returns:
- This builder, for chaining
-
absorbResult
Combines the currently buildingDataTransactionResult
with the one provided. Usually, this means that there is some merging of theValue.Immutable
s based onKey
. If this builder already has anValue.Immutable
as being successfully offered, and the provided result shows the same key as being rejected, the rejectedValue.Immutable
will remain in the final result.- Parameters:
result
- The result to merge- Returns:
- This builder, for chaining
-
build
Builds a newDataTransactionResult
with the providingList
s ofValue.Immutable
s that are successfully offered,Value.Immutable
s that were replaced, andValue.Immutable
s that were rejected.- Specified by:
build
in interfaceAbstractBuilder<DataTransactionResult>
- Returns:
- The newly created transaction result
-
from
Description copied from interface:CopyableBuilder
Resets this builder to the values of the given built object.- Specified by:
from
in interfaceCopyableBuilder<DataTransactionResult,
DataTransactionResult.Builder> - Parameters:
value
- The built object- Returns:
- This builder, for chaining
-
reset
Description copied from interface:Builder
Resets this builder to a "default" state such that there is no remaining data to set. This is to be the presumed "default" state.- Specified by:
reset
in interfaceBuilder<DataTransactionResult,
DataTransactionResult.Builder> - Specified by:
reset
in interfaceResettableBuilder<DataTransactionResult,
DataTransactionResult.Builder> - Returns:
- This builder, for chaining
-