Class CouchbaseQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- com.couchbase.client.java.datastructures.collections.CouchbaseQueue<E>
-
- Type Parameters:
E
- the type of values in the queue.
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Queue<E>
@Committed @Public public class CouchbaseQueue<E> extends AbstractQueue<E>
A CouchbaseQueue is aQueue
backed by aCouchbase
document (more specifically aJSON array
). Note that as such, a CouchbaseQueue is restricted to the types that aJSON array
can contain. JSON objects and sub-arrays can be represented asJsonObject
andJsonArray
respectively. Null values are not allowed as they have special meaning for thepeek()
andAbstractQueue.remove()
methods of a queue.- Since:
- 2.3.6
- Author:
- Simon Baslé, Subhashni Balakrishnan
-
-
Constructor Summary
Constructors Constructor Description CouchbaseQueue(String id, Bucket bucket)
CouchbaseQueue(String id, Bucket bucket, E... content)
CouchbaseQueue(String id, Bucket bucket, Collection<? extends E> content)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Iterator<E>
iterator()
boolean
offer(E e)
E
peek()
E
poll()
int
size()
-
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Constructor Detail
-
CouchbaseQueue
public CouchbaseQueue(String id, Bucket bucket)
Create a newCouchbase-backed
Queue, backed by the document identified byid
inbucket
. Note that if the document already exists, its content will be used as initial content for this collection. Otherwise it is created empty.- Parameters:
id
- the id of the Couchbase document to back the queue.bucket
- theBucket
through which to interact with the document.
-
CouchbaseQueue
public CouchbaseQueue(String id, Bucket bucket, E... content)
Create a newCouchbase-backed
Queue, backed by the document identified byid
inbucket
. Note that if the document already exists, its content is reset to the values provided. Note that if you don't provide any value as a vararg, theCouchbaseQueue(String, Bucket)
constructor will be invoked instead, which will use pre-existing values as content. To create a new Queue and force it to be empty, useCouchbaseQueue(String, Bucket, Collection)
with an empty collection.- Parameters:
id
- the id of the Couchbase document to back the queue.bucket
- theBucket
through which to interact with the document.content
- vararg of the elements to initially store in the Queue.
-
CouchbaseQueue
public CouchbaseQueue(String id, Bucket bucket, Collection<? extends E> content)
Create a newCouchbase-backed
Queue, backed by the document identified byid
inbucket
. Note that if the document already exists, its content is reset to the values provided in thecontent
Collection.- Parameters:
id
- the id of the Couchbase document to back the queue.bucket
- theBucket
through which to interact with the document.content
- collection of the elements to initially store in the Queue, in iteration order.
-
-
Method Detail
-
iterator
public Iterator<E> iterator()
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<E>
- Overrides:
clear
in classAbstractQueue<E>
-
offer
public boolean offer(E e)
-
poll
public E poll()
-
peek
public E peek()
-
-