Class CouchbaseList
java.lang.Object
org.springframework.data.couchbase.core.mapping.CouchbaseList
- All Implemented Interfaces:
CouchbaseStorable
A
CouchbaseList
is an abstract list that represents an array stored in a (most of the times JSON) document.
This CouchbaseList
is part of the potentially nested structure inside one or more CouchbaseDocument
s.
It can also contain them recursively, depending on how the document is modeled.
-
Constructor Summary
ConstructorDescriptionCreate a new (empty) list.CouchbaseList
(List<Object> initialPayload) Create a new list with a given payload on construction.CouchbaseList
(List<Object> initialPayload, SimpleTypeHolder simpleTypeHolder) Create a new list with a given payload on construction and an existingSimpleTypeHolder
.CouchbaseList
(SimpleTypeHolder simpleTypeHolder) Create a new (empty) list with an existingSimpleTypeHolder
. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
containsValue
(Object value) Returns true if it contains the given value.export()
Returns the current payload, including all recursive elements.final Object
get
(int index) Return the stored element at the given index.final boolean
isEmpty()
Checks if the underlying payload is empty or not.final CouchbaseList
Add content to the underlying list.final int
size()
Returns the size of the attributes in this document (not nested).final int
size
(boolean recursive) Retruns the size of the attributes in this and recursive documents.toString()
A string reprensation of the payload.
-
Constructor Details
-
CouchbaseList
public CouchbaseList()Create a new (empty) list. -
CouchbaseList
Create a new list with a given payload on construction.- Parameters:
initialPayload
- the initial data to store.
-
CouchbaseList
Create a new (empty) list with an existingSimpleTypeHolder
.- Parameters:
simpleTypeHolder
- context instance.
-
CouchbaseList
Create a new list with a given payload on construction and an existingSimpleTypeHolder
.- Parameters:
initialPayload
- the initial data to store.simpleTypeHolder
- context instance.
-
-
Method Details
-
put
Add content to the underlying list.- Parameters:
value
- the value to be added.- Returns:
- the
CouchbaseList
object for chaining purposes.
-
get
Return the stored element at the given index.- Parameters:
index
- the index where the document is located.- Returns:
- the found object (or null if nothing found).
-
size
public final int size()Returns the size of the attributes in this document (not nested).- Returns:
- the size of the attributes in this document (not nested).
-
size
public final int size(boolean recursive) Retruns the size of the attributes in this and recursive documents.- Parameters:
recursive
- wheter nested attributes should be taken into account.- Returns:
- the size of the attributes in this and recursive documents.
-
export
Returns the current payload, including all recursive elements.It either returns the raw results or makes sure that the recusrive elements are also exported properly.
- Returns:
-
containsValue
Returns true if it contains the given value.- Parameters:
value
- the value to check for.- Returns:
- true if it contains the specified value.
-
isEmpty
public final boolean isEmpty()Checks if the underlying payload is empty or not.- Returns:
- whether the underlying payload is empty or not.
-
toString
A string reprensation of the payload.
-