Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
io.realm

Colección de interfaz RealmCollection

Implemented interfaces:

  • java.util.Collection

  • java.lang.Iterable

RealmCollection is the root of the collection hierarchy that Realm supports. It defines operations on data collections and the behavior that they will have in all implementations of RealmCollection s.

Realm collections are "live" views to the underlying data. This means that they automatically will be kept up to date. As a consequence, using methods like Collections.unmodifiableCollection(Collection) will not prevent a collection from being modified.

Modificador y Tipo
Método y descripción

public double

String fieldName
)

Devuelve el promedio de un campo dado.

public booleano

Object object
)

Tests whether this Collection contains the specified object.

public booleano

This deletes all objects in the collection from the underlying Realm as well as from the collection.

public booleano

Checks if a collection has finished loading its data yet.

public booleano

Checks if the collection is managed by Realm.

public booleano

Checks if the collection is still valid to use, i.e., the io.realm.Realm instance hasn't been closed.

public booleano

load ()

Bloquea la recopilación hasta que todos los datos estén disponibles.

public Number

max (
String fieldName
)

Finds the maximum value of a field.

public Date

String fieldName
)

Encuentra la fecha máxima.

public Number

min (
String fieldName
)

Finds the minimum value of a field.

public Date

String fieldName
)

Finds the minimum date.

public Number

sum (
String fieldName
)

Calculates the sum of a given field.

Returns a RealmQuery , which can be used to query for specific objects from this collection.

public double average (
String fieldName
)

Devuelve el promedio de un campo dado.

Parámetros

  • fieldName - el campo sobre el que calcular el promedio. Sólo se admiten campos numéricos.

Devuelve

el promedio del campo indicado entre los objetos de los resultados de la query. Esto será del tipo double para todos los campos de tipo numérico. Si no existen objetos o todos tienen null como valor para el campo dado, 0 será devuelto. Al calcular el promedio, se ignoran los objetos con valores null.

Throws

public boolean contains (
Object object
)

Tests whether this Collection contains the specified object. Returns true if and only if at least one element elem in this Collection meets following requirement: (object==null ? elem==null : object.equals(elem)) .

Parámetros

  • object - the object to search for.

Devuelve

true if object is an element of this Collection , false otherwise.

Throws

  • NullPointerException - if the object to look for is null and this Collection doesn't support null elements.

public boolean deleteAllFromRealm ()

This deletes all objects in the collection from the underlying Realm as well as from the collection.

Devuelve

true si se borraron objetos, false de lo contrario.

Throws

public boolean isLoaded ()

Checks if a collection has finished loading its data yet.

Devuelve

true if data has been loaded and is available, false if data is still being loaded.

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 false , the collection is unmanaged. An unmanaged collection is just a normal java collection, so it will not be live updated.

Devuelve

true if this is a managed RealmCollection , false otherwise.

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 true for an unmanaged collection.

Devuelve

true if it is still valid to use or an unmanaged collection, false otherwise.

public boolean load ()

Bloquea la recopilación hasta que todos los datos estén disponibles.

Devuelve

true si los datos se pudieran cargar correctamente, false de lo contrario.

public Number max (
String fieldName
)

Finds the maximum value of a field.

Parámetros

  • fieldName - el campo para buscar un máximo en. Sólo se admiten campos numéricos.

Devuelve

si no existen objetos o todos tienen null como valor para el campo dado, se devolverá null. En caso contrario, se devuelve el valor máximo. Al determinar el valor máximo, se ignoran los objetos con valores null.

Throws

public Date maxDate (
String fieldName
)

Encuentra la fecha máxima.

Parámetros

  • fieldName - El campo donde se busca la fecha máxima. Si fieldName no es del tipo Fecha, se genera una excepción.

Devuelve

Si no existen objetos o si todos tienen null como valor para el campo de fecha dado, se devolverá null. De lo contrario, se devuelve la fecha máxima. Al determinar la fecha máxima, los objetos con valores null se ignoran.

Throws

public Number min (
String fieldName
)

Finds the minimum value of a field.

Parámetros

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

Devuelve

si no existen objetos o todos tienen null como valor para el campo dado, se devolverá null. De lo contrario, se devuelve el valor mínimo. Al determinar el valor mínimo, se ignoran los objetos con valores null.

Throws

public Date minDate (
String fieldName
)

Finds the minimum date.

Parámetros

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

Devuelve

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.

Throws

public Number sum (
String fieldName
)

Calculates the sum of a given field.

Parámetros

  • fieldName - the field to sum. Only number fields are supported.

Devuelve

la suma. Si no existen objetos o todos tienen null como valor para el campo dado, se devolverá 0. A la hora de calcular la suma, se ignoran los objetos con valores null.

Throws

public RealmQuery where ()

Returns a RealmQuery , which can be used to query for specific objects from this collection.

Devuelve

un objeto de RealmQuery.

Throws

Tip

Volver

RealmChangeListener

En esta página