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 a
Set
backed by a Couchbase
document (more
specifically a JSON array
).
Note that a CouchbaseArraySet is restricted to primitive types (the types that a JSON array
can contain, except JsonObject
and JsonArray
). 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 byid
in the given Couchbasebucket
.CouchbaseArraySet(String id, Bucket bucket, Set<? extends T> initialData)
Create a newCouchbaseArraySet
, backed by the document identified byid
in the given Couchbasebucket
. -
Method Summary
Modifier and Type Method Description boolean
add(T t)
void
clear()
boolean
contains(Object t)
protected void
enforcePrimitive(Object t)
Verify that the type of object t is compatible with CouchbaseArraySet storage.boolean
isEmpty()
Iterator<T>
iterator()
boolean
remove(Object t)
protected boolean
safeEquals(Object expected, Object tested)
int
size()
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 Details
-
CouchbaseArraySet
Create a newCouchbaseArraySet
, backed by the document identified byid
in 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
- theBucket
through which to interact with the document.
-
CouchbaseArraySet
Create a newCouchbaseArraySet
, backed by the document identified byid
in the given Couchbasebucket
. Note that if the document already exists, its content is reset to the values copied from the givendata
Map. 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
- theBucket
through which to interact with the document.initialData
- Set of the elements to initially store in the CouchbaseArraySet.
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceSet<T>
- Specified by:
size
in classAbstractCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T>
- Specified by:
isEmpty
in interfaceSet<T>
- Overrides:
isEmpty
in classAbstractCollection<T>
-
contains
- Specified by:
contains
in interfaceCollection<T>
- Specified by:
contains
in interfaceSet<T>
- Overrides:
contains
in classAbstractCollection<T>
-
iterator
-
add
- Specified by:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceSet<T>
- Overrides:
add
in classAbstractCollection<T>
-
remove
- Specified by:
remove
in interfaceCollection<T>
- Specified by:
remove
in interfaceSet<T>
- Overrides:
remove
in classAbstractCollection<T>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T>
- Specified by:
clear
in interfaceSet<T>
- Overrides:
clear
in classAbstractCollection<T>
-
enforcePrimitive
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.
-
safeEquals
-