max

abstract fun <T : Any> max(property: String, type: KClass<T>): RealmScalarNullableQuery<T>

Finds the maximum value of a property.

A reified version of this method is also available as an extension function, query.max<YourClass>(...). Import io.realm.query.max to access it.

Return

a RealmScalarQuery returning the maximum value for the given property represented as a T. If no objects exist or they all have null as the value for the given property, null will be returned by the query. Otherwise, the maximum value is returned. When determining the maximum value, objects with null values are ignored.

Parameters

property

the property on which to find the maximum value. Only Number properties are supported.

type

the type of the resulting aggregated value, which may or may not coincide with the type of the property itself.

Throws

if the property is not a Number or a Char, or if type cannot be used to represent the property.