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)
Creating a RealmQuery instance.
|
RealmQuery(RealmResults realmList,
java.lang.Class<E> clazz)
Create 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()
Count 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()
Find all objects that fulfill the query conditions.
|
RealmResults<E> |
findAllSorted(java.lang.String fieldName)
Find 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)
Find all objects that fulfill the query conditions and sorted by specific field names.
|
RealmResults<E> |
findAllSorted(java.lang.String fieldName,
boolean sortAscending)
Find 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)
Find 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)
Find all objects that fulfill the query conditions and sorted by specific field names in
ascending order.
|
E |
findFirst()
Find the first object that fulfills the query conditions.
|
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> |
isNotNull(java.lang.String fieldName)
Test if a field is not
null . |
RealmQuery<E> |
isNull(java.lang.String fieldName)
Test if a field is
null . |
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)
Find the maximum value of a field.
|
java.util.Date |
maximumDate(java.lang.String fieldName)
Find 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)
Find the minimum value of a field.
|
java.util.Date |
minimumDate(java.lang.String fieldName)
Find 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)
Calculate 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.java.lang.RuntimeException
- Any other error.public RealmQuery(RealmResults realmList, java.lang.Class<E> clazz)
realmList
- The @{link io.realm.RealmResults} to queryclazz
- The class to queryjava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> isNull(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> 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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.public RealmQuery<E> equalTo(java.lang.String fieldName, java.lang.Short value)
fieldName
- the field to compare.value
- the value to compare withjava.lang.IllegalArgumentException
- if one or more arguments do not match class or
field type.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.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.java.lang.RuntimeException
- if any other error happens.public RealmQuery<E> greaterThan(java.lang.String fieldName, int value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThan(java.lang.String fieldName, long value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThan(java.lang.String fieldName, double value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThan(java.lang.String fieldName, float value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThan(java.lang.String fieldName, java.util.Date value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, int value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, long value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, double value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, float value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> greaterThanOrEqualTo(java.lang.String fieldName, java.util.Date value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThan(java.lang.String fieldName, int value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThan(java.lang.String fieldName, long value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThan(java.lang.String fieldName, double value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThan(java.lang.String fieldName, float value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThan(java.lang.String fieldName, java.util.Date value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, int value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, long value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, double value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, float value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> lessThanOrEqualTo(java.lang.String fieldName, java.util.Date value)
fieldName
- The field to comparevalue
- The value to compare withjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> between(java.lang.String fieldName, int from, int to)
fieldName
- The field to comparefrom
- Lowest value (inclusive)to
- Highest value (inclusive)java.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> between(java.lang.String fieldName, long from, long to)
fieldName
- The field to comparefrom
- Lowest value (inclusive)to
- Highest value (inclusive)java.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> between(java.lang.String fieldName, double from, double to)
fieldName
- The field to comparefrom
- Lowest value (inclusive)to
- Highest value (inclusive)java.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> between(java.lang.String fieldName, float from, float to)
fieldName
- The field to comparefrom
- Lowest value (inclusive)to
- Highest value (inclusive)java.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> between(java.lang.String fieldName, java.util.Date from, java.util.Date to)
fieldName
- The field to comparefrom
- Lowest value (inclusive)to
- Highest value (inclusive)java.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> contains(java.lang.String fieldName, java.lang.String value)
fieldName
- The field to comparevalue
- The substringjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> contains(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- The field to comparevalue
- The substringcaseSensitive
- 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 typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> beginsWith(java.lang.String fieldName, java.lang.String value)
fieldName
- The field to comparevalue
- The stringjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> beginsWith(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- The field to comparevalue
- The substringcaseSensitive
- 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 typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> endsWith(java.lang.String fieldName, java.lang.String value)
fieldName
- The field to comparevalue
- The stringjava.lang.IllegalArgumentException
- One or more arguments do not match class or
field typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> endsWith(java.lang.String fieldName, java.lang.String value, boolean caseSensitive)
fieldName
- The field to comparevalue
- The substringcaseSensitive
- 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 typejava.lang.RuntimeException
- Any other errorpublic RealmQuery<E> beginGroup()
endGroup()
.endGroup()
public RealmQuery<E> endGroup()
beginGroup()
.beginGroup()
public RealmQuery<E> or()
public RealmQuery<E> not()
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 namejava.lang.UnsupportedOperationException
- The query is not valid ("syntax error")public double sumDouble(java.lang.String fieldName)
sum(String)
instead.fieldName
- The field namejava.lang.UnsupportedOperationException
- The query is not valid ("syntax error")public double sumFloat(java.lang.String fieldName)
sum(String)
instead.fieldName
- The field namejava.lang.UnsupportedOperationException
- 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 namejava.lang.UnsupportedOperationException
- The query is not valid ("syntax error")public double averageDouble(java.lang.String fieldName)
average(String)
instead.fieldName
- The field namejava.lang.UnsupportedOperationException
- The query is not valid ("syntax error")public double averageFloat(java.lang.String fieldName)
average(String)
instead.fieldName
- The field namejava.lang.UnsupportedOperationException
- 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 namejava.lang.UnsupportedOperationException
- 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 namejava.lang.UnsupportedOperationException
- 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 namejava.lang.UnsupportedOperationException
- 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
- 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 namejava.lang.UnsupportedOperationException
- 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 namejava.lang.UnsupportedOperationException
- 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 namejava.lang.UnsupportedOperationException
- 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
- the query is not valid ("syntax error").public long count()
java.lang.UnsupportedOperationException
- 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.java.lang.RuntimeException
- Any other errorRealmResults
public RealmResults<E> findAllSorted(java.lang.String fieldName, boolean sortAscending)
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> 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> findAllSorted(java.lang.String[] fieldNames, boolean[] sortAscending)
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> 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> 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 E findFirst()
null
if no object matches the query conditions.java.lang.RuntimeException
- Any other error.RealmObject