Class CouchbaseArraySet<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<T>
-
- com.couchbase.client.java.datastructures.collections.CouchbaseArraySet<T>
-
- Type Parameters:
T- the type of values in the set.
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
@Committed @Public public class CouchbaseArraySet<T> extends AbstractSet<T>
A CouchbaseArraySet is aSetbacked by aCouchbasedocument (more specifically aJSON array). Note that a CouchbaseArraySet is restricted to primitive types (the types that aJSON arraycan contain, exceptJsonObjectandJsonArray). null entries are supported.- Since:
- 2.3.6
- Author:
- Simon Baslé, Subhashni Balakrishnan
-
-
Constructor Summary
Constructors Constructor Description CouchbaseArraySet(String id, Bucket bucket)Create a newCouchbaseArraySet, backed by the document identified byidin the given Couchbasebucket.CouchbaseArraySet(String id, Bucket bucket, Set<? extends T> initialData)Create a newCouchbaseArraySet, backed by the document identified byidin the given Couchbasebucket.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T t)voidclear()booleancontains(Object t)protected voidenforcePrimitive(Object t)Verify that the type of object t is compatible with CouchbaseArraySet storage.booleanisEmpty()Iterator<T>iterator()booleanremove(Object t)protected booleansafeEquals(Object expected, Object tested)intsize()-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
CouchbaseArraySet
public CouchbaseArraySet(String id, Bucket bucket)
Create a newCouchbaseArraySet, backed by the document identified byidin the given Couchbasebucket. 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 set.bucket- theBucketthrough which to interact with the document.
-
CouchbaseArraySet
public CouchbaseArraySet(String id, Bucket bucket, Set<? extends T> initialData)
Create a newCouchbaseArraySet, backed by the document identified byidin the given Couchbasebucket. Note that if the document already exists, its content is reset to the values copied from the givendataMap. A null or empty data map will re-initialize any pre-existing document to an empty content.- Parameters:
id- the id of the Couchbase document to back the set.bucket- theBucketthrough which to interact with the document.initialData- Set of the elements to initially store in the CouchbaseArraySet.
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceSet<T>- Specified by:
sizein classAbstractCollection<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceSet<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
contains
public boolean contains(Object t)
- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceSet<T>- Overrides:
containsin classAbstractCollection<T>
-
add
public boolean add(T t)
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractCollection<T>
-
remove
public boolean remove(Object t)
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractCollection<T>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceSet<T>- Overrides:
clearin classAbstractCollection<T>
-
enforcePrimitive
protected void enforcePrimitive(Object t) throws ClassCastException
Verify that the type of object t is compatible with CouchbaseArraySet storage.- Parameters:
t- the object to check.- Throws:
ClassCastException- if the object is incompatible.
-
-