java.lang.Object
org.springframework.data.couchbase.core.mapping.CouchbaseList
All Implemented Interfaces:
CouchbaseStorable

public class CouchbaseList extends Object implements 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 CouchbaseDocuments. It can also contain them recursively, depending on how the document is modeled.

  • Constructor Details

    • CouchbaseList

      public CouchbaseList()
      Create a new (empty) list.
    • CouchbaseList

      public CouchbaseList(List<Object> initialPayload)
      Create a new list with a given payload on construction.
      Parameters:
      initialPayload - the initial data to store.
    • CouchbaseList

      public CouchbaseList(SimpleTypeHolder simpleTypeHolder)
      Create a new (empty) list with an existing SimpleTypeHolder.
      Parameters:
      simpleTypeHolder - context instance.
    • CouchbaseList

      public CouchbaseList(List<Object> initialPayload, SimpleTypeHolder simpleTypeHolder)
      Create a new list with a given payload on construction and an existing SimpleTypeHolder.
      Parameters:
      initialPayload - the initial data to store.
      simpleTypeHolder - context instance.
  • Method Details

    • put

      public final CouchbaseList put(Object value)
      Add content to the underlying list.
      Parameters:
      value - the value to be added.
      Returns:
      the CouchbaseList object for chaining purposes.
    • get

      public final Object get(int index)
      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

      public final List<Object> 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

      public final boolean containsValue(Object value)
      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

      public String toString()
      A string reprensation of the payload.
      Overrides:
      toString in class Object
      Returns:
      the underlying payload as a string representation for easier debugging.