-
- All Implemented Interfaces:
public final class PatchingKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any> Unituse(PatchOp<T> $self, Function1<T, Unit> block)Allows using a patch operation by passing an appropriate value to the given block function. final static <T extends Any> Unituse(UpdateOp<T> $self, Function1<T, Unit> block)Allows using a patch update operation by passing an appropriate value to the given block function. final static <T extends Any> TgetOrDefaultNullifyingDelete(PatchOp<T> $self, Function0<T> current)Retrieves a value depending on the patch operation where deleteis mapped tonullandnoneis mapped to the value returned by given the current function.final static <T extends Any> TgetOrElse(PatchOp<T> $self, Function1<Boolean, Void> block)Retrieves a value for setoperations and calls the block function fordeleteandnoneoperations.final static <T extends Any, R extends Any> PatchOp<R>map(PatchOp<T> $self, Function1<T, R> transform)Transforms the value for setoperations by calling the provided transform function and creating a new set operation; all other patch operations (deleteandnone) are returned as is.final static <T extends Any, R extends Any> UpdateOp<R>map(UpdateOp<T> $self, Function1<T, R> transform)Transforms the value for setoperations by calling the provided transform function and creating a new set operation;noneoperations are returned as is.final static <T extends Any> TgetOrDefault(UpdateOp<T> $self, Function0<T> current)Retrieves a value depending on the patch operation where noneis mapped to the value returned by given the current function.-
-
Method Detail
-
use
final static <T extends Any> Unit use(PatchOp<T> $self, Function1<T, Unit> block)
Allows using a patch operation by passing an appropriate value to the given block function.
- Parameters:
block- Usage function to be called (or not) based on the patch operation.
-
use
final static <T extends Any> Unit use(UpdateOp<T> $self, Function1<T, Unit> block)
Allows using a patch update operation by passing an appropriate value to the given block function.
- Parameters:
block- Usage function to be called (or not) based on the patch operation.
-
getOrDefaultNullifyingDelete
final static <T extends Any> T getOrDefaultNullifyingDelete(PatchOp<T> $self, Function0<T> current)
Retrieves a value depending on the patch operation where
deleteis mapped tonullandnoneis mapped to the value returned by given the current function.- Parameters:
current- Value to be returned when the patch operation isnone.
-
getOrElse
final static <T extends Any> T getOrElse(PatchOp<T> $self, Function1<Boolean, Void> block)
Retrieves a value for
setoperations and calls the block function fordeleteandnoneoperations.set- If the patch is a set, the new value will be returned.delete- If the patch is a delete, block is called with thedeletedparameter set totrue.none- If the patch is none, block is called with thedeletedparameter set tofalse.
The provided block is function that returns Nothing and therefore must throw an exception or some other equivalent operation.
- Parameters:
block- Function to be called fordeleteornoneoperations.
-
map
final static <T extends Any, R extends Any> PatchOp<R> map(PatchOp<T> $self, Function1<T, R> transform)
Transforms the value for
setoperations by calling the provided transform function and creating a new set operation; all other patch operations (deleteandnone) are returned as is.- Parameters:
transform- Function to be called forsetoperations to transform the value.
-
map
final static <T extends Any, R extends Any> UpdateOp<R> map(UpdateOp<T> $self, Function1<T, R> transform)
Transforms the value for
setoperations by calling the provided transform function and creating a new set operation;noneoperations are returned as is.- Parameters:
transform- Function to be called forsetoperations to transform the value.
-
getOrDefault
final static <T extends Any> T getOrDefault(UpdateOp<T> $self, Function0<T> current)
Retrieves a value depending on the patch operation where
noneis mapped to the value returned by given the current function.- Parameters:
current- Value to be returned when the patch operation isnone.
-
-
-
-