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

Clase RealmSet

java.lang.Object
io.realm.RealmSet

Implemented interfaces:

RealmSet is a collection that contains no duplicate elements.Similarly to RealmList s, a RealmSet can operate in managed and unmanaged modes. In managed mode a RealmSet persists all its contents inside a Realm whereas in unmanaged mode it functions like a HashSet .

Managed RealmSets can only be created by Realm and will automatically update their content whenever the underlying Realm is updated. Managed RealmSet can only be accessed using the getter that points to a RealmSet field of a RealmObject .

Unmanaged elements in this set can be added to a Realm using the Realm.copyToRealm(Iterable, ImportFlag...) method.

Warning: the following methods are not supported for classes containing set fields yet:

Constructor and Description

Instantiates a RealmSet in unmanaged mode.

Crea una instancia de un RealmSet en modo no administrado con otra colección.

BaseRealm baseRealm,
OsSet osSet,
)

Instancia un RealmSet en modo gestionado.

BaseRealm baseRealm,
OsSet osSet,
String className
)

Instancia un RealmSet en modo gestionado.

Modificador y Tipo
Método y descripción

public booleano

add (
E e
)

public booleano

public void

Agrega un escuchador de cambios a este RealmSet .

public void

Agrega un escuchador de cambios a este RealmSet .

public double

String fieldName
)

Devuelve el promedio de un campo dado.

public void

public booleano

Prueba si esto Collection contiene el objeto especificado.

public booleano

public booleano

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

public RealmSet

public Class

public String

public booleano

public booleano

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 Iterator

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 booleano

public booleano

public void

Removes all user-defined change listeners.

public void

Removes the specified change listener.

public void

Removes the specified change listener.

public booleano

public int

size ()

public Number

sum (
String fieldName
)

Calculates the sum of a given field.

public T

toArray <T >(
T[] a
)

public Object

Returns a RealmQuery, which can be used to query for specific objects of this class.

  • Methods inherited from class java.lang.Object : getClass , hashCode , equals , clone , toString , notify , notifyAll , wait , wait , wait , finalize

public RealmSet ()

Instantiates a RealmSet in unmanaged mode.

public RealmSet (
)

Crea una instancia de un RealmSet en modo no administrado con otra colección.

Parámetros

  • collection - la colección con la que se poblará inicialmente el conjunto.

public RealmSet (
BaseRealm baseRealm,
OsSet osSet,
)

Crea una instancia de un RealmSet en modo administrado. Realm utiliza este constructor internamente.

Parámetros

  • baseRealm -

  • osSet -

  • valueClass -

public RealmSet (
BaseRealm baseRealm,
OsSet osSet,
String className
)

Instantiates a RealmSet in managed mode. This constructor is used internally by a Dynamic Realm.

Parámetros

  • baseRealm -

  • osSet -

  • className -

public boolean add (
E e
)

Agrega un escuchador de cambios a este RealmSet .

Registering a change listener will not prevent the underlying RealmSet from being garbage collected. If the RealmSet is garbage collected, the change listener will stop being triggered. To avoid this, keep a strong reference for as long as appropriate e.g. in a class variable.

public class MyActivity extends Activity {
private RealmSet<Dog> dogs; // Strong reference to keep listeners alive
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dogs = realm.where(Person.class).findFirst().getDogs();
dogs.addChangeListener(new SetChangeListener<Dog>() {
@Override
public void onChange(RealmSet<Dog> set, SetChangeSet changeSet) {
// React to change
}
});
}
}

Parámetros

  • listener - the listener to be notified.

Throws

Agrega un escuchador de cambios a este RealmSet .

Registering a change listener will not prevent the underlying RealmSet from being garbage collected. If the RealmSet is garbage collected, the change listener will stop being triggered. To avoid this, keep a strong reference for as long as appropriate e.g. in a class variable.

public class MyActivity extends Activity {
private RealmSet<Dog> dogs; // Strong reference to keep listeners alive
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dogs = realm.where(Person.class).findFirst().getDogs();
dogs.addChangeListener(new RealmChangeListener<RealmSet<Dog>>() {
@Override
public void onChange(RealmSet<Dog> map) {
// React to change
}
});
}
}

Parámetros

  • listener - the listener to be notified.

Throws

public double average (
String fieldName
)

Devuelve el promedio de un campo dado.

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.

public void clear ()

public boolean contains (
)

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)) .

Devuelve

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

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.

public RealmSet freeze ()

public boolean isEmpty ()

public boolean isFrozen ()

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 Iterator iterator ()

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.

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.

public Date maxDate (
String fieldName
)

Encuentra la fecha máxima.

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.

public Number min (
String fieldName
)

Finds the minimum value of a field.

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.

public Date minDate (
String fieldName
)

Finds the minimum date.

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.

public boolean remove (
)

Removes all user-defined change listeners.

Throws

Tip

Removes the specified change listener.

Parámetros

  • listener - the change listener to be removed.

Throws

Removes the specified change listener.

Parámetros

  • listener - the change listener to be removed.

Throws

public int size ()

public Number sum (
String fieldName
)

Calculates the sum of a given field.

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.

public T toArray <T >(
T[] a
)
public Object toArray ()

public RealmQuery where ()

Returns a RealmQuery, which can be used to query for specific objects of this class.

Devuelve

un objeto de RealmQuery.

Throws

Volver

RealmSchema

En esta página