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
DataTransactionResults. The common
use is for both implementations of DataHolders, and various
ChangeDataHolderEvent.ValueChanges.-
Method Summary
Modifier and TypeMethodDescriptionabsorbResult(DataTransactionResult result) Combines the currently buildingDataTransactionResultwith the one provided.build()Builds a newDataTransactionResultwith the providingLists ofValue.Immutables that are successfully offered,Value.Immutables that were replaced, andValue.Immutables 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.Typeto the provided type.success(Iterable<Value.Immutable<?>> values) success(Value.Immutable<?> value)
-
Method Details
-
result
Sets the expectantDataTransactionResult.Typeto the provided type. ADataTransactionResultmust 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.Immutableto theListof "replaced"Value.Immutables. The replaced values are always copied for everyDataTransactionResultfor referencing.- Parameters:
value- The value to replace- Returns:
- This builder, for chaining
-
replace
Adds the providedValue.Immutables to theListof "replaced"Value.Immutables. The replaced values are always copied for everyDataTransactionResultfor referencing.- Parameters:
values- The values to replace- Returns:
- This builder, for chaining
-
reject
Adds the providedValue.Immutableto theListof "rejected"Value.Immutables. The rejected values are always copied for everyDataTransactionResultfor referencing.- Parameters:
value- The values to reject- Returns:
- This builder, for chaining
-
reject
Adds the providedValue.Immutables to theListof "rejected"Value.Immutables. The rejected values are always copied for everyDataTransactionResultfor referencing.- Parameters:
values- The values to reject- Returns:
- This builder, for chaining
-
success
Adds the providedValue.Immutableto theListof "successful"Value.Immutables. The successful values are always copied for everyDataTransactionResultfor referencing.- Parameters:
value- The value that was successfully provided- Returns:
- This builder, for chaining
-
success
Adds the providedValue.Immutables to theListof "successful"Value.Immutables. The rejected values are always copied for everyDataTransactionResultfor referencing.- Parameters:
values- The values that were successfully provided- Returns:
- This builder, for chaining
-
absorbResult
Combines the currently buildingDataTransactionResultwith the one provided. Usually, this means that there is some merging of theValue.Immutables based onKey. If this builder already has anValue.Immutableas being successfully offered, and the provided result shows the same key as being rejected, the rejectedValue.Immutablewill remain in the final result.- Parameters:
result- The result to merge- Returns:
- This builder, for chaining
-
build
Builds a newDataTransactionResultwith the providingLists ofValue.Immutables that are successfully offered,Value.Immutables that were replaced, andValue.Immutables that were rejected.- Specified by:
buildin interfaceAbstractBuilder<DataTransactionResult>- Returns:
- The newly created transaction result
-
from
Description copied from interface:CopyableBuilderResets this builder to the values of the given built object.- Specified by:
fromin interfaceCopyableBuilder<DataTransactionResult,DataTransactionResult.Builder> - Parameters:
value- The built object- Returns:
- This builder, for chaining
-
reset
Description copied from interface:BuilderResets 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:
resetin interfaceBuilder<DataTransactionResult,DataTransactionResult.Builder> - Specified by:
resetin interfaceResettableBuilder<DataTransactionResult,DataTransactionResult.Builder> - Returns:
- This builder, for chaining
-