Package org.spongepowered.api.data
Class DataTransactionResult.Builder
- java.lang.Object
-
- org.spongepowered.api.data.DataTransactionResult.Builder
-
- All Implemented Interfaces:
Buildable.Builder<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 buildingDataTransactionResult
s. The common use is for both implementations ofDataHolder
s, and variousChangeDataHolderEvent.ValueChange
s.
-
-
Method Summary
-
-
-
Method Detail
-
result
public DataTransactionResult.Builder result(DataTransactionResult.Type type)
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
public DataTransactionResult.Builder replace(Value.Immutable<?> value)
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
public DataTransactionResult.Builder replace(Iterable<Value.Immutable<?>> values)
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
public DataTransactionResult.Builder reject(Value.Immutable<?> value)
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
public DataTransactionResult.Builder reject(Iterable<Value.Immutable<?>> values)
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
public DataTransactionResult.Builder success(Value.Immutable<?> value)
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
public DataTransactionResult.Builder success(Iterable<Value.Immutable<?>> values)
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
public DataTransactionResult.Builder absorbResult(DataTransactionResult result)
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
public DataTransactionResult 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 interfaceBuildable.Builder<DataTransactionResult>
- Returns:
- The newly created transaction result
-
from
public DataTransactionResult.Builder from(DataTransactionResult value)
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
public DataTransactionResult.Builder 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
-
-