Class RealmSet
On this page
- io.realm
- Constructors
- Method Summary
- Inherited Methods
- Constructor Detail
- Method Detail
- add
- addAll
- addChangeListener
- average
- clear
- contains
- containsAll
- deleteAllFromRealm
- freeze
- getValueClass
- getValueClassName
- isEmpty
- isFrozen
- isLoaded
- isManaged
- isValid
- iterator
- load
- max
- maxDate
- min
- minDate
- remove
- removeAll
- removeAllChangeListeners
- removeChangeListener
- retainAll
- size
- sum
- toArray
- where
io.realm
Implemented interfaces:
RealmSet is a collection that contains no duplicate elements.Similarly to RealmList s, a RealmSet can operate in managed and unmanaged modes. In managed mode a RealmSet persists all its contents inside a Realm whereas in unmanaged mode it functions like a HashSet .
Managed RealmSets can only be created by Realm and will automatically update their content whenever the underlying Realm is updated. Managed RealmSet can only be accessed using the getter that points to a RealmSet field of a RealmObject .
Unmanaged elements in this set can be added to a Realm using the Realm.copyToRealm(Iterable, ImportFlag...) method.
Warning: the following methods are not supported for classes containing set fields yet:
Realm.createAllFromJson(Class, String)
Realm.createAllFromJson(Class, InputStream)
Realm.createObjectFromJson(Class, String)
Realm.createObjectFromJson(Class, InputStream)}
Realm.createOrUpdateAllFromJson(Class, String)
Realm.createOrUpdateAllFromJson(Class, InputStream)
Realm.createOrUpdateObjectFromJson(Class, String)
Realm.createOrUpdateObjectFromJson(Class, InputStream)
Constructors
Constructor and Description |
---|
RealmSet () Instantiates a RealmSet in unmanaged mode. |
Instantiates a RealmSet in unmanaged mode with another collection. |
Instantiates a RealmSet in managed mode. |
Method Summary
Modifier and Type | Method and Description |
---|---|
public boolean | |
public boolean | |
public void | Adds a change listener to this RealmSet . |
public void | Adds a change listener to this RealmSet . |
public double | |
public void | clear () |
public boolean | |
public boolean | |
public boolean | This deletes all objects in the collection from the underlying Realm as well as from the collection. |
public RealmSet | freeze () |
public Class | |
public String | |
public boolean | isEmpty () |
public boolean | isFrozen () |
public boolean | isLoaded () Checks if a collection has finished loading its data yet. |
public boolean | isManaged () Checks if the collection is managed by Realm. |
public boolean | isValid () Checks if the collection is still valid to use, i.e., the io.realm.Realm instance hasn't been closed. |
public Iterator | iterator () |
public boolean | load () Blocks the collection until all data are available. |
public Number | |
public Date | |
public Number | |
public Date | |
public boolean | |
public boolean | |
public void | Removes all user-defined change listeners. |
public void | Removes the specified change listener. |
public void | Removes the specified change listener. |
public boolean | |
public int | size () |
public Number | |
public T | |
public Object | toArray () |
public RealmQuery | where () Returns a RealmQuery, which can be used to query for specific objects of this class. |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Constructor Detail
public RealmSet () |
---|
Instantiates a RealmSet in unmanaged mode. |
Instantiates a RealmSet in unmanaged mode with another collection. Parameters
|
Instantiates a RealmSet in managed mode. This constructor is used internally by Realm. Parameters
|
Method Detail
add
addAll
addChangeListener
Adds a change listener to this RealmSet . Registering a change listener will not prevent the underlying RealmSet from being garbage collected. If the RealmSet is garbage collected, the change listener will stop being triggered. To avoid this, keep a strong reference for as long as appropriate e.g. in a class variable.
Parameters
Throws
|
Adds a change listener to this RealmSet . Registering a change listener will not prevent the underlying RealmSet from being garbage collected. If the RealmSet is garbage collected, the change listener will stop being triggered. To avoid this, keep a strong reference for as long as appropriate e.g. in a class variable.
Parameters
Throws
|
average
Returns the average of a given field. Returns the average for the given field amongst objects in query results. This will be of type double for all types of number fields. If no objects exist or they all have |
clear
public void clear () |
---|
contains
Tests whether this Returns
|
containsAll
deleteAllFromRealm
public boolean deleteAllFromRealm () |
---|
This deletes all objects in the collection from the underlying Realm as well as from the collection. Returns
|
freeze
getValueClass
public Class getValueClass () |
---|
getValueClassName
public String getValueClassName () |
---|
isEmpty
public boolean isEmpty () |
---|
isFrozen
public boolean isFrozen () |
---|
isLoaded
public boolean isLoaded () |
---|
Checks if a collection has finished loading its data yet. Returns
|
isManaged
public boolean isManaged () |
---|
Checks if the collection is managed by Realm. A managed collection is just a wrapper around the data in the underlying Realm file. On Looper threads, a managed collection will be live-updated so it always points to the latest data. Managed collections are thread confined so that they cannot be accessed from other threads than the one that created them.If this method returns Returns
|
isValid
public boolean isValid () |
---|
Checks if the collection is still valid to use, i.e., the io.realm.Realm instance hasn't been closed. It will always return Returns
|
iterator
load
public boolean load () |
---|
Blocks the collection until all data are available. Returns
|
max
maxDate
min
minDate
remove
removeAll
removeAllChangeListeners
public void removeAllChangeListeners () |
---|
Removes all user-defined change listeners. Throws
|
removeChangeListener
Removes the specified change listener. Parameters
Throws
|
Removes the specified change listener. Parameters
Throws
|
retainAll
size
public int size () |
---|
sum
toArray
where
public RealmQuery where () |
---|
Returns a RealmQuery, which can be used to query for specific objects of this class. Returns a RealmQuery object. Throws
|