@InterfaceStability.Experimental @InterfaceAudience.Public public class MutationSpec<T> extends Object
Utility class to create specs for the sub-document API’s multi-mutation
operations.
Modifier and Type | Method and Description |
---|---|
static <T> MutationSpec |
addUnique(String path,
T value,
boolean createParents)
Creates a
MutationSpec to insert a value in an existing array only if the value isn’t already contained in the array (by way of string comparison). |
static <T> MutationSpec |
arrayInsert(String path,
T value)
Creates a
MutationSpec to insert into an existing array at a specific position (denoted in the path, eg. |
static MutationSpec<Long> |
counter(String path,
long delta,
boolean createParents)
Creates a
MutationSpec to increment/decrement a numerical fragment in a JSON document. |
boolean |
createParents() |
static <T> MutationSpec |
extend(String path,
T value,
ExtendDirection direction,
boolean createParents)
Creates a
MutationSpec to extend an existing array, prepending or appending the value depending on the given direction. |
T |
fragment() |
static <T> MutationSpec |
insert(String path,
T fragment,
boolean createParents)
Creates a
MutationSpec to insert a fragment provided the last element of the path doesn’t exists. |
String |
path() |
static <T> MutationSpec |
remove(String path)
Creates a
MutationSpec to remove an entry in a JSON document (scalar, array element, dictionary entry, whole array or dictionary, depending on the path). |
static <T> MutationSpec |
replace(String path,
T fragment)
Creates a
MutationSpec to replace an existing value by the fragment. |
String |
toString() |
Mutation |
type() |
static <T> MutationSpec |
upsert(String path,
T fragment,
boolean createParents)
Creates a
MutationSpec to insert a fragment, replacing the old value if the path exists. |
public String path()
public T fragment()
public boolean createParents()
public static <T> MutationSpec replace(String path, T fragment)
Creates a MutationSpec
to replace an existing value by the fragment.
public static <T> MutationSpec upsert(String path, T fragment, boolean createParents)
Creates a MutationSpec
to insert a fragment, replacing the old value if the path exists.
createParents
- in case elements of the path other than the last one don’t exist, set to true to create them.Bucket.upsertIn(DocumentFragment, boolean, PersistTo, ReplicateTo)
public static <T> MutationSpec insert(String path, T fragment, boolean createParents)
Creates a MutationSpec
to insert a fragment provided the last element of the path doesn’t exists.
createParents
- in case elements of the path other than the last one don’t exist, set to true to create them.Bucket.insertIn(DocumentFragment, boolean, PersistTo, ReplicateTo)
public static <T> MutationSpec extend(String path, T value, ExtendDirection direction, boolean createParents)
Creates a MutationSpec
to extend an existing array, prepending or appending the value depending on the given direction.
direction
- the position at which to extend the array.createParents
- in case elements of the path other than the last one don’t exist, set to true to create them.Bucket.extendIn(DocumentFragment, ExtendDirection, boolean, PersistTo, ReplicateTo)
public static <T> MutationSpec arrayInsert(String path, T value)
Creates a MutationSpec
to insert into an existing array at a specific position (denoted in the path, eg. “sub.array[2]”).
public static <T> MutationSpec addUnique(String path, T value, boolean createParents)
Creates a MutationSpec
to insert a value in an existing array only if the value isn’t already contained in the array (by way of string comparison).
public static MutationSpec<Long> counter(String path, long delta, boolean createParents)
Creates a MutationSpec
to increment/decrement a numerical fragment in a JSON document. If the value (last element of the path) doesn’t exist the counter is created and takes the value of the delta.
delta
- the value to increment or decrement the counter by.Bucket.counterIn(DocumentFragment, boolean, PersistTo, ReplicateTo)
public static <T> MutationSpec remove(String path)
Creates a MutationSpec
to remove an entry in a JSON document (scalar, array element, dictionary entry, whole array or dictionary, depending on the path).
Copyright © 2015 Couchbase, Inc.