E
- the class of the objects to be queried.public class RealmQuery<E extends RealmObject>
extends java.lang.Object
Realm
or a RealmResults
using the Builder
pattern. The query is executed using either findAll()
or findFirst()
The input to many of the query functions take a field name as String. Note that this is not type safe. If a model class is refactored care has to be taken to not break any queries.
A Realm
is unordered, which means that there is no guarantee that querying a Realm will return the
objects in the order they where inserted. Use findAllSorted(String)
and similar methods if a specific order
is required.
A RealmQuery cannot be passed between different threads.
Realm.where(Class)
,
RealmResults.where()
Modifier and Type | Field and Description |
---|---|
static boolean |
CASE_INSENSITIVE |
static boolean |
CASE_SENSITIVE |
Constructor and Description |
---|
RealmQuery(Realm realm,
java.lang.Class<E> clazz)
Creates a RealmQuery instance.
|
RealmQuery(RealmResults realmResults,
java.lang.Class<E> clazz)
Creates a RealmQuery instance from a @{link io.realm.RealmResults}.
|
Modifier and Type | Method and Description |
---|---|
double |
average(java.lang.String fieldName)
Returns the average of a given field.
|
double |
averageDouble(java.lang.String fieldName)
Deprecated.
please use
average(String) instead. |
double |
averageFloat(java.lang.String fieldName)
Deprecated.
please use
average(String) instead. |
double |
averageInt(java.lang.String fieldName)
Deprecated.
please use
average(String) instead. |
RealmQuery<E> |
beginGroup()
Begin grouping of conditions ("left parenthesis").
|
RealmQuery<E> |
beginsWith(java.lang.String fieldName,
java.lang.String value)
Condition that the value of field begins with the specified string.
|
RealmQuery<E> |
beginsWith(java.lang.String fieldName,
java.lang.String value,
boolean caseSensitive)
Condition that the value of field begins with the specified substring.
|
RealmQuery<E> |
between(java.lang.String fieldName,
java.util.Date from,
java.util.Date to)
Between condition.
|
RealmQuery<E> |
between(java.lang.String fieldName,
double from,
double to)
Between condition.
|
RealmQuery<E> |
between(java.lang.String fieldName,
float from,
float to)
Between condition.
|
RealmQuery<E> |
between(java.lang.String fieldName,
int from,
int to)
Between condition.
|
RealmQuery<E> |
between(java.lang.String fieldName,
long from,
long to)
Between condition.
|
RealmQuery<E> |
contains(java.lang.String fieldName,
java.lang.String value)
Condition that value of field contains the specified substring.
|
RealmQuery<E> |
contains(java.lang.String fieldName,
java.lang.String value,
boolean caseSensitive)
Condition that value of field contains the specified substring.
|
long |
count()
Counts the number of objects that fulfill the query conditions.
|
RealmQuery<E> |
endGroup()
End grouping of conditions ("right parenthesis") which was opened by a call to
beginGroup() . |
RealmQuery<E> |
endsWith(java.lang.String fieldName,
java.lang.String value)
Condition that the value of field ends with the specified string.
|
RealmQuery<E> |
endsWith(java.lang.String fieldName,
java.lang.String value,
boolean caseSensitive)
Condition that the value of field ends with the specified substring.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.Boolean value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.Byte value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.util.Date value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.Double value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.Float value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.Integer value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.Long value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.Short value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.String value)
Equal-to comparison.
|
RealmQuery<E> |
equalTo(java.lang.String fieldName,
java.lang.String value,
boolean caseSensitive)
Equal-to comparison.
|
RealmResults<E> |
findAll()
Finds all objects that fulfill the query conditions.
|
RealmResults<E> |
findAllAsync()
Finds all objects that fulfill the query conditions and sorted by specific field name.
|
RealmResults<E> |
findAllSorted(java.lang.String fieldName)
Finds all objects that fulfill the query conditions and sorted by specific field name in ascending order.
|
RealmResults<E> |
findAllSorted(java.lang.String[] fieldNames,
boolean[] sortAscending)
Finds all objects that fulfill the query conditions and sorted by specific field names.
|
RealmResults<E> |
findAllSorted(java.lang.String fieldName,
boolean sortAscending)
Finds all objects that fulfill the query conditions and sorted by specific field name.
|
RealmResults<E> |
findAllSorted(java.lang.String fieldName1,
boolean sortAscending1,
java.lang.String fieldName2,
boolean sortAscending2)
Finds all objects that fulfill the query conditions and sorted by specific field names in ascending order.
|
RealmResults<E> |
findAllSorted(java.lang.String fieldName1,
boolean sortAscending1,
java.lang.String fieldName2,
boolean sortAscending2,
java.lang.String fieldName3,
boolean sortAscending3)
Finds all objects that fulfill the query conditions and sorted by specific field names in
ascending order.
|
RealmResults<E> |
findAllSortedAsync(java.lang.String fieldName)
Similar to
findAllSorted(String) but runs asynchronously on a worker thread
This method is only available from a Looper thread. |
RealmResults<E> |
findAllSortedAsync(java.lang.String[] fieldNames,
boolean[] sortAscending)
Similar to
findAllSorted(String[], boolean[]) but runs asynchronously from a worker thread. |
RealmResults<E> |
findAllSortedAsync(java.lang.String fieldName,
boolean sortAscending)
Similar to
findAllSorted(String, boolean) but runs asynchronously on a worker thread (Need a Realm
opened from a looper thread to work). |
RealmResults<E> |
findAllSortedAsync(java.lang.String fieldName1,
boolean sortAscending1,
java.lang.String fieldName2,
boolean sortAscending2)
Similar to
findAllSorted(String, boolean, String, boolean) but runs asynchronously on a worker thread. |
RealmResults<E> |
findAllSortedAsync(java.lang.String fieldName1,
boolean sortAscending1,
java.lang.String fieldName2,
boolean sortAscending2,
java.lang.String fieldName3,
boolean sortAscending3)
Similar to
findAllSorted(String, boolean, String, boolean, String, boolean) but runs asynchronously on
a worker thread. |
E |
findFirst()
Finds the first object that fulfills the query conditions.
|
E |
findFirstAsync()
Similar to
findFirst() but runs asynchronously on a worker thread
This method is only available from a Looper thread. |
ArgumentsHolder |
getArgument() |
RealmQuery<E> |
greaterThan(java.lang.String fieldName,
java.util.Date value)
Greater-than comparison.
|
RealmQuery<E> |
greaterThan(java.lang.String fieldName,
double value)
Greater-than comparison.
|
RealmQuery<E> |
greaterThan(java.lang.String fieldName,
float value)
Greater-than comparison.
|
RealmQuery<E> |
greaterThan(java.lang.String fieldName,
int value)
Greater-than comparison.
|
RealmQuery<E> |
greaterThan(java.lang.String fieldName,
long value)
Greater-than comparison.
|
RealmQuery<E> |
greaterThanOrEqualTo(java.lang.String fieldName,
java.util.Date value)
Greater-than-or-equal-to comparison.
|
RealmQuery<E> |
greaterThanOrEqualTo(java.lang.String fieldName,
double value)
Greater-than-or-equal-to comparison.
|
RealmQuery<E> |
greaterThanOrEqualTo(java.lang.String fieldName,
float value)
Greater-than-or-equal-to comparison.
|
RealmQuery<E> |
greaterThanOrEqualTo(java.lang.String fieldName,
int value)
Greater-than-or-equal-to comparison.
|
RealmQuery<E> |
greaterThanOrEqualTo(java.lang.String fieldName,
long value)
Greater-than-or-equal-to comparison.
|
RealmQuery<E> |
isEmpty(java.lang.String fieldName)
Condition that find values that are considered "empty", i.e.
|
RealmQuery<E> |
isNotNull(java.lang.String fieldName)
Tests if a field is not
null . |
RealmQuery<E> |
isNull(java.lang.String fieldName)
Tests if a field is
null . |
boolean |
isValid()
Checks if
RealmQuery is still valid to use i.e. |
RealmQuery<E> |
lessThan(java.lang.String fieldName,
java.util.Date value)
Less-than comparison.
|
RealmQuery<E> |
lessThan(java.lang.String fieldName,
double value)
Less-than comparison.
|
RealmQuery<E> |
lessThan(java.lang.String fieldName,
float value)
Less-than comparison.
|
RealmQuery<E> |
lessThan(java.lang.String fieldName,
int value)
Less-than comparison.
|
RealmQuery<E> |
lessThan(java.lang.String fieldName,
long value)
Less-than comparison.
|
RealmQuery<E> |
lessThanOrEqualTo(java.lang.String fieldName,
java.util.Date value)
Less-than-or-equal-to comparison.
|
RealmQuery<E> |
lessThanOrEqualTo(java.lang.String fieldName,
double value)
Less-than-or-equal-to comparison.
|
RealmQuery<E> |
lessThanOrEqualTo(java.lang.String fieldName,
float value)
Less-than-or-equal-to comparison.
|
RealmQuery<E> |
lessThanOrEqualTo(java.lang.String fieldName,
int value)
Less-than-or-equal-to comparison.
|
RealmQuery<E> |
lessThanOrEqualTo(java.lang.String fieldName,
long value)
Less-than-or-equal-to comparison.
|
java.lang.Number |
max(java.lang.String fieldName)
Finds the maximum value of a field.
|
java.util.Date |
maximumDate(java.lang.String fieldName)
Finds the maximum value of a field.
|
double |
maximumDouble(java.lang.String fieldName)
Deprecated.
please use
max(String) instead. |
float |
maximumFloat(java.lang.String fieldName)
Deprecated.
please use
max(String) instead. |
long |
maximumInt(java.lang.String fieldName)
Deprecated.
please use
max(String) instead. |
java.lang.Number |
min(java.lang.String fieldName)
Finds the minimum value of a field.
|
java.util.Date |
minimumDate(java.lang.String fieldName)
Finds the minimum value of a field.
|
double |
minimumDouble(java.lang.String fieldName)
Deprecated.
please use
min(String) instead. |
float |
minimumFloat(java.lang.String fieldName)
Deprecated.
please use
min(String) instead. |
long |
minimumInt(java.lang.String fieldName)
Deprecated.
please use
min(String) instead. |
RealmQuery<E> |
not()
Negate condition.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.Boolean value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.Byte value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.util.Date value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.Double value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.Float value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.Integer value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.Long value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.Short value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.String value)
Not-equal-to comparison.
|
RealmQuery<E> |
notEqualTo(java.lang.String fieldName,
java.lang.String value,
boolean caseSensitive)
Not-equal-to comparison.
|
RealmQuery<E> |
or()
Logical-or two conditions.
|
java.lang.Number |
sum(java.lang.String fieldName)
Calculates the sum of a given field.
|
double |
sumDouble(java.lang.String fieldName)
Deprecated.
please use
sum(String) instead. |
double |
sumFloat(java.lang.String fieldName)
Deprecated.
please use
sum(String) instead. |
long |
sumInt(java.lang.String fieldName)
Deprecated.
please use
sum(String) instead. |
public static final boolean CASE_SENSITIVE
public static final boolean CASE_INSENSITIVE
public RealmQuery(Realm realm, java.lang.Class<E> clazz)
realm
- the realm to query within.clazz
- the class to query.public RealmQuery(RealmResults realmResults, java.lang.Class<E> clazz)
realmResults
- the @{link io.realm.RealmResults} to query.clazz
- the class to query.public boolean isValid()
RealmQuery
is still valid to use i.e. the Realm
instance hasn't been
closed and any parent RealmResults
is still valid.true
if still valid to use, false
otherwise.public RealmQuery<E> isNull(java.lang.String fieldName)
null
. Only works for nullable fields.
For link queries, if any part of the link path is null
the whole path is considered to be null
e.g. isNull("linkField.stringField")
will be considered to be null
if either linkField
or
linkField.stringField
is null
.fieldName
- the field name.java.lang.IllegalArgumentException
- if the field is not nullable.for further infomation.
public RealmQuery<E> isNotNull(java.lang.String fieldName)
null
. Only works for nullable fields.fieldName
- the field name.java.lang.IllegalArgumentException
- if the field is not nullable.for further infomation.
public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.String value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- the field to compare.value
- the value to compare with.caseSensitive
- if true, substring matching is case sensitive. Setting this to false only works for English
locale characters.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Byte value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Short value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Integer value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Long value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Double value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Float value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Boolean value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> equalTo(java.lang.String fieldName, java.util.Date value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.String value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- the field to compare.value
- the value to compare with.caseSensitive
- if true, substring matching is case sensitive. Setting this to false only works for English
locale characters.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.Byte value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.Short value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.Integer value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.Long value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.Double value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.Float value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.lang.Boolean value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> notEqualTo(java.lang.String fieldName, java.util.Date value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThan(java.lang.String fieldName, int value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThan(java.lang.String fieldName, long value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThan(java.lang.String fieldName, double value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThan(java.lang.String fieldName, float value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThan(java.lang.String fieldName, java.util.Date value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, int value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, long value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, double value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, float value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field typepublic RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, java.util.Date value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThan(java.lang.String fieldName, int value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThan(java.lang.String fieldName, long value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThan(java.lang.String fieldName, double value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThan(java.lang.String fieldName, float value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThan(java.lang.String fieldName, java.util.Date value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, int value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, long value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, double value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, float value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, java.util.Date value)
fieldName
- the field to compare.value
- the value to compare with.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> between(java.lang.String fieldName, int from, int to)
fieldName
- the field to compare.from
- lowest value (inclusive).to
- highest value (inclusive).java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> between(java.lang.String fieldName, long from, long to)
fieldName
- the field to compare.from
- lowest value (inclusive).to
- highest value (inclusive).java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> between(java.lang.String fieldName, double from, double to)
fieldName
- the field to compare.from
- lowest value (inclusive).to
- highest value (inclusive).java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> between(java.lang.String fieldName, float from, float to)
fieldName
- the field to compare.from
- lowest value (inclusive).to
- highest value (inclusive).java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> between(java.lang.String fieldName, java.util.Date from, java.util.Date to)
fieldName
- the field to compare.from
- lowest value (inclusive).to
- highest value (inclusive).java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> contains(java.lang.String fieldName, java.lang.String value)
fieldName
- the field to compare.value
- the substring.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> contains(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- the field to compare.value
- the substring.caseSensitive
- if true, substring matching is case sensitive. Setting this to false only works for English
locale characters.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> beginsWith(java.lang.String fieldName, java.lang.String value)
fieldName
- the field to compare.value
- the string.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> beginsWith(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- the field to compare.value
- the substring.caseSensitive
- if true, substring matching is case sensitive. Setting this to false only works for English
locale characters.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> endsWith(java.lang.String fieldName, java.lang.String value)
fieldName
- the field to compare.value
- the string.java.lang.IllegalArgumentException
- if one or more arguments do not match class or field type.public RealmQuery<E> endsWith(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- the field to compare.value
- the substring.caseSensitive
- if true, substring matching is case sensitive. Setting this to false only works for English
locale characters.java.lang.IllegalArgumentException
- One or more arguments do not match class or field type.public RealmQuery<E> beginGroup()
endGroup()
.endGroup()
public RealmQuery<E> endGroup()
beginGroup()
.beginGroup()
public RealmQuery<E> or()
public RealmQuery<E> not()
public RealmQuery<E> isEmpty(java.lang.String fieldName)
fieldName
- the field to compare.java.lang.IllegalArgumentException
- if the field name isn't valid or its type isn't either a RealmList,
String or byte array.public java.lang.Number sum(java.lang.String fieldName)
fieldName
- the field to sum. Only number fields are supported.null
as the value for the given field, 0
will be returned. When computing the sum, objects with null
values are ignored.java.lang.IllegalArgumentException
- if the field is not a number type.public long sumInt(java.lang.String fieldName)
sum(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public double sumDouble(java.lang.String fieldName)
sum(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public double sumFloat(java.lang.String fieldName)
sum(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public double average(java.lang.String fieldName)
fieldName
- the field to calculate average on. Only number fields are supported.null
as the value for the given field,
0
will be returned. When computing the average, objects with null
values are ignored.java.lang.IllegalArgumentException
- if the field is not a number type.public double averageInt(java.lang.String fieldName)
average(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public double averageDouble(java.lang.String fieldName)
average(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public double averageFloat(java.lang.String fieldName)
average(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public java.lang.Number min(java.lang.String fieldName)
fieldName
- the field to look for a minimum on. Only number fields are supported.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.java.lang.IllegalArgumentException
- if the field is not a number type.public long minimumInt(java.lang.String fieldName)
min(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").java.lang.NullPointerException
- if no objects exist or they all have null
as the value for the
given field.public double minimumDouble(java.lang.String fieldName)
min(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").java.lang.NullPointerException
- if no objects exist or they all have null
as the value for the
given field.public float minimumFloat(java.lang.String fieldName)
min(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").java.lang.NullPointerException
- if no objects exist or they all have null
as the value for the
given field.public java.util.Date minimumDate(java.lang.String fieldName)
fieldName
- the field namenull
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.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public java.lang.Number max(java.lang.String fieldName)
fieldName
- the field to look for a maximum on. Only number fields are supported.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.java.lang.IllegalArgumentException
- if the field is not a number type.public long maximumInt(java.lang.String fieldName)
max(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").java.lang.NullPointerException
- if no objects exist or they all have null
as the value for the
given field.public double maximumDouble(java.lang.String fieldName)
max(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").java.lang.NullPointerException
- if no objects exist or they all have null
as the value for the
given field.public float maximumFloat(java.lang.String fieldName)
max(String)
instead.fieldName
- the field name.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").java.lang.NullPointerException
- if no objects exist or they all have null
as the value for the
given field.public java.util.Date maximumDate(java.lang.String fieldName)
fieldName
- the field name.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.java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public long count()
java.lang.UnsupportedOperationException
- if the query is not valid ("syntax error").public RealmResults<E> findAll()
RealmResults
containing objects. If no objects match the condition, a list with zero
objects is returned.RealmResults
public RealmResults<E> findAllAsync()
RealmResults
. Users need to register a listener
RealmResults.addChangeListener(RealmChangeListener)
to be notified when the query completes.RealmResults
public RealmResults<E> findAllSorted(java.lang.String fieldName, boolean sortAscending)
Sorting is currently limited to character sets in 'Latin Basic', 'Latin Supplement', 'Latin Extended A', 'Latin Extended B' (UTF-8 range 0-591). For other character sets, sorting will have no effect.
fieldName
- the field name to sort by.sortAscending
- sort ascending if SORT_ORDER_ASCENDING
, sort descending
if SORT_ORDER_DESCENDING
RealmResults
containing objects. If no objects match the condition, a list with zero
objects is returned.java.lang.IllegalArgumentException
- if field name does not exist.public RealmResults<E> findAllSortedAsync(java.lang.String fieldName, boolean sortAscending)
findAllSorted(String, boolean)
but runs asynchronously on a worker thread (Need a Realm
opened from a looper thread to work).RealmResults
. Users need to register a listener
RealmResults.addChangeListener(RealmChangeListener)
to be notified when the query completes.java.lang.IllegalArgumentException
- if field name does not exist.public RealmResults<E> findAllSorted(java.lang.String fieldName)
fieldName
- the field name to sort by.RealmResults
containing objects. If no objects match the condition, a list with zero
objects is returned.java.lang.IllegalArgumentException
- if field name does not exist.public RealmResults<E> findAllSortedAsync(java.lang.String fieldName)
findAllSorted(String)
but runs asynchronously on a worker thread
This method is only available from a Looper thread.RealmResults
. Users need to register a listener
RealmResults.addChangeListener(RealmChangeListener)
to be notified when the query completes.java.lang.IllegalArgumentException
- if field name does not exist.public RealmResults<E> findAllSorted(java.lang.String[] fieldNames, boolean[] sortAscending)
Sorting is currently limited to character sets in 'Latin Basic', 'Latin Supplement', 'Latin Extended A', 'Latin Extended B' (UTF-8 range 0-591). For other character sets, sorting will have no effect.
fieldNames
- an array of field names to sort by.sortAscending
- sort ascending if SORT_ORDER_ASCENDING
, sort descending if
SORT_ORDER_DESCENDING
.RealmResults
containing objects. If no objects match the condition, a list with zero
objects is returned.java.lang.IllegalArgumentException
- if a field name does not exist.public RealmResults<E> findAllSortedAsync(java.lang.String[] fieldNames, boolean[] sortAscending)
findAllSorted(String[], boolean[])
but runs asynchronously from a worker thread.
This method is only available from a Looper thread.RealmResults
. Users need to register a listener
RealmResults.addChangeListener(RealmChangeListener)
to be notified when the query completes.RealmResults
public RealmResults<E> findAllSorted(java.lang.String fieldName1, boolean sortAscending1, java.lang.String fieldName2, boolean sortAscending2)
fieldName1
- first field namesortAscending1
- sort order for first fieldfieldName2
- second field namesortAscending2
- sort order for second fieldRealmResults
containing objects. If no objects match the condition, a list with zero
objects is returned.java.lang.IllegalArgumentException
- if a field name does not exist.public RealmResults<E> findAllSortedAsync(java.lang.String fieldName1, boolean sortAscending1, java.lang.String fieldName2, boolean sortAscending2)
findAllSorted(String, boolean, String, boolean)
but runs asynchronously on a worker thread.
This method is only available from a Looper thread.RealmResults
. Users need to register a listener
RealmResults.addChangeListener(RealmChangeListener)
to be notified when the query completes.java.lang.IllegalArgumentException
- if a field name does not exist.public RealmResults<E> findAllSorted(java.lang.String fieldName1, boolean sortAscending1, java.lang.String fieldName2, boolean sortAscending2, java.lang.String fieldName3, boolean sortAscending3)
fieldName1
- first field namesortAscending1
- sort order for first fieldfieldName2
- second field namesortAscending2
- sort order for second fieldfieldName3
- third field namesortAscending3
- sort order for third fieldRealmResults
containing objects. If no objects match the condition, a list with zero
objects is returned.java.lang.IllegalArgumentException
- if a field name does not exist.public RealmResults<E> findAllSortedAsync(java.lang.String fieldName1, boolean sortAscending1, java.lang.String fieldName2, boolean sortAscending2, java.lang.String fieldName3, boolean sortAscending3)
findAllSorted(String, boolean, String, boolean, String, boolean)
but runs asynchronously on
a worker thread.
This method is only available from a Looper thread.RealmResults
. Users need to register a listener
RealmResults.addChangeListener(RealmChangeListener)
to be notified when the query completes.java.lang.IllegalArgumentException
- if a field name does not exist.public E findFirst()
null
if no object matches the query conditions.RealmObject
public E findFirstAsync()
findFirst()
but runs asynchronously on a worker thread
This method is only available from a Looper thread.RealmObject
. Users need to register a listener
RealmObject.addChangeListener(io.realm.RealmChangeListener)
to be notified when the query completes.public ArgumentsHolder getArgument()