This class holds all the matches of a RealmQuery for a given Realm. The objects are not copied from
the Realm to the RealmResults list, but are just referenced from the RealmResult instead. This saves memory and
increases speed.

RealmResults are live views, which means that if it is on an Looper thread, it will automatically
update its query results after a transaction has been committed. If on a non-looper thread, BaseRealm.refresh()
must be called to update the results.

Updates to RealmObjects from a RealmResults list must be done from within a transaction and the modified objects are
persisted to the Realm file during the commit of the transaction.

A RealmResults object cannot be passed between different threads.

Notice that a RealmResults is never null not even in the case where it contains no objects. You should always
use the size() method to check if a RealmResults is empty or not.

If a RealmResults is built on RealmList through RealmList.where(), it will become empty when the source
RealmList gets deleted.

RealmResults can contain more elements than Integer.MAX_VALUE.
In that case, you can access only first Integer.MAX_VALUE elements in it.

min

fieldName - the field to look for a minimum on. Only number fields are supported.

Returns:

if no objects exist or they all have null as the value for the given field, null will be
returned. Otherwise the minimum value is returned. When determining the minimum value, objects with null
values are ignored.

minDate

fieldName - the field to look for the minimum date. If fieldName is not of Date type, an exception is
thrown.

Returns:

if no objects exist or they all have null as the value for the given date field, null
will be returned. Otherwise the minimum date is returned. When determining the minimum date, objects with
null values are ignored.

max

fieldName - the field to look for a maximum on. Only number fields are supported.

Returns:

if no objects exist or they all have null as the value for the given field, null will be
returned. Otherwise the maximum value is returned. When determining the maximum value, objects with null
values are ignored.

maxDate

fieldName - the field to look for the maximum date. If fieldName is not of Date type, an exception is
thrown.

Returns:

if no objects exist or they all have null as the value for the given date field, null
will be returned. Otherwise the maximum date is returned. When determining the maximum date, objects with
null values are ignored.

Throws:

java.lang.IllegalArgumentException - if fieldName is not a Date field.

average

fieldName - the field to calculate average on. Only number fields are supported.

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 null as the value for the given field,
0 will be returned. When computing the average, objects with null values are ignored.

distinctAsync

Asynchronously returns a distinct set of objects of a specific class. If the result is
sorted, the first object will be returned in case of multiple occurrences, otherwise it is
undefined which object is returned.

distinct

Returns a distinct set of objects from a specific class. When multiple distinct fields are
given, all unique combinations of values in the fields will be returned. In case of multiple
matches, it is undefined which object is returned. Unless the result is sorted, then the
first object will be returned.

Parameters:

firstFieldName - first field name to use when finding distinct objects.

remainingFieldNames - remaining field names when determining all unique combinations of field values.

isLoaded

public boolean isLoaded()

Returns true if the results are not yet loaded, false if they are still loading. Synchronous
query methods like findAll() will always return true, while asynchronous query methods like
findAllAsync() will return false until the results are available.
This will return true if called for a standalone object (created outside of Realm).

removeChangeListener

removeChangeListeners

public void removeChangeListeners()

Removes all registered listeners.

asObservable

public <any> asObservable()

Returns an Rx Observable that monitors changes to this RealmResults. It will emit the current RealmResults when
subscribed to. RealmResults will continually be emitted as the RealmResults are updated -
onComplete will never be called.
If you would like the asObservable() to stop emitting items you can instruct RxJava to
only emit only the first item by using the first() operator:

realm.where(Foo.class).findAllAsync().asObservable()
.filter(results -> results.isLoaded())
.first()
.subscribe( ... ) // You only get the results once

Returns:

RxJava Observable that only calls onNext. It will never call onComplete or OnError.

Throws:

java.lang.UnsupportedOperationException - if the required RxJava framework is not on the classpath or the
corresponding Realm instance doesn't support RxJava.