io.realm
Implemented interfaces:
In Realm you define your RealmObject classes by sub-classing RealmObject and adding fields to be persisted. You then create your objects within a Realm, and use your custom subclasses instead of using the RealmObject class directly.An annotation processor will create a proxy class for your RealmObject subclass.
The following field data types are supported:
boolean/Boolean
short/Short
int/Entero
largo/Largo
float/Float
double/Double
byte[]
String
fecha
UUID
org.bson.types.Decimal128
org.bson.types.ObjectId
Cualquier subclase de RealmObject
RealmList
RealmDictionary
Los tipos short , int y long se asignan a long cuando se almacenan dentro de un reino.
La única restricción que tiene un RealmObject es que no se permite que los campos sean finales o volátiles. Está permitido cualquier método, así como campos públicos. Al proporcionar constructores personalizados, se debe declarar un constructor público sin argumentos.
Los campos anotados con io.realm.annotations.Ignore no tienen estas restricciones y no requieren un getter ni un setter.
Realm will create indexes for fields annotated with io.realm.annotations.Index . This will speedup queries but will have a negative impact on inserts and updates.
No se puede pasar un RealmObject entre diferentes hilos.
Constructores
Constructor and Description |
|---|
RealmObject () |
Resumen del método
Modificador y Tipo | Método y descripción |
|---|---|
public static void | Agrega un detector de cambios a un RealmObject que se activará si se modifica algún campo de valor o un campo RealmObject referenciado, o si se modifica el campo RealmList en sí. |
public static void | Adds a change listener to a RealmObject to get detailed information about the changes. |
public final void | Agrega un detector de cambios a este RealmObject que se activará si se modifica algún campo de valor o un campo RealmObject referenciado, o si se modifica el campo RealmList en sí. |
public final void | Adds a change listener to this RealmObject to get detailed information about changes. |
public static <any> | Returns an Rx Observable that monitors changes to this RealmObject. |
public final <any> | asChangesetObservable <E >() Returns an Rx Observable that monitors changes to this RealmObject. |
public static <any> | Returns an RxJava Flowable that monitors changes to this RealmObject. |
public final <any> | asFlowable <E >() Returns an RxJava Flowable that monitors changes to this RealmObject. |
public static void | Elimina el objeto del reino con el que está asociado actualmente. |
public final void | Deletes the object from the Realm it is currently associated to. |
public static E | Returns a frozen snapshot of this object. |
public final E | freeze <E >() Returns a frozen snapshot of this object. |
public static Realm | returns Realm instance where the |
public Realm | getRealm () Devuelve la instancia Realm a la que pertenece este RealmObject. |
public static boolean | Indica si este RealmObject está congelado o no. |
public final boolean | isFrozen () Indica si este RealmObject está congelado o no. |
public static boolean | Verifica si la query utilizada para encontrar este RealmObject se ha completado. |
public final boolean | isLoaded () Verifica si la query utilizada para encontrar este RealmObject se ha completado. |
public static boolean | Checks if this object is managed by Realm. |
public booleano | isManaged () Checks if this object is managed by Realm. |
public static boolean | Checks if the RealmObject is still valid to use i.e., the RealmObject hasn't been deleted nor has the io.realm.Realm been closed. |
public final boolean | isValid () Checks if the RealmObject is still valid to use i.e., the RealmObject hasn't been deleted nor has the io.realm.Realm been closed. |
public static boolean | Makes an asynchronous query blocking. |
public final boolean | load () Makes an asynchronous query blocking. |
public static void | Removes all registered listeners from the given RealmObject. |
public final void | Removes all registered listeners. |
public static void | Removes a previously registered listener on the given RealmObject. |
public static void | Removes a previously registered listener on the given RealmObject. |
public final void | Removes a previously registered listener. |
public final void | Removes a previously registered listener. |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass,hashCode,equals,clone,toString,notify,notifyAll,wait,wait,wait,finalize
Detalle del constructor
public RealmObject () |
|---|
Detalle del método
addChangeListener
Adds a change listener to a RealmObject that will be triggered if any value field or referenced RealmObject field is changed, or the RealmList field itself is changed.Registering a change listener will not prevent the underlying RealmObject from being garbage collected. If the RealmObject 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. Parámetros
Throws
|
Añade un detector de cambios a un RealmObject para obtener información detallada sobre los cambios. El detector se activará si se modifica algún campo de valor, un campo RealmObject referenciado o el propio campo RealmList. Registrar un detector de cambios no impedirá que el RealmObject subyacente sea objeto de recolección de basura. Si el RealmObject es objeto de recolección de basura, el detector de cambios dejará de activarse. Para evitar esto, mantenga una referencia fuerte durante el tiempo que sea necesario, por ejemplo, en una variable de clase. Parámetros
Throws
|
Adds a change listener to this RealmObject that will be triggered if any value field or referenced RealmObject field is changed, or the RealmList field itself is changed.Registering a change listener will not prevent the underlying RealmObject from being garbage collected. If the RealmObject 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. Parámetros
Throws
|
Adds a change listener to this RealmObject to get detailed information about changes. The listener will be triggered if any value field or referenced RealmObject field is changed, or the RealmList field itself is changed.Registering a change listener will not prevent the underlying RealmObject from being garbage collected. If the RealmObject 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. Parámetros
Throws
|
asChangesetObservable
Devuelve un Observable Rx que monitoriza los cambios en este RealmObject. Emitirá el RealmObject actual al suscribirse. Por cada actualización del RealmObject, se enviará un par compuesto por el RealmObject y el ObjectChangeSet. El conjunto de cambios será The RealmObject will continually be emitted as it is updated - Los elementos emitidos por Realm Observables están congelados (consulta freeze() ). Esto significa que son inmutables y se pueden leer en cualquier hilo. Realm Observables always emit items from the thread holding the live Realm. This means that if you need to do further processing, it is recommend to observe the values on a computation scheduler: Parámetros
Devuelve Observable de RxJava que solo llama a Throws
|
public final <any> asChangesetObservable <E >() | |||||
|---|---|---|---|---|---|
Devuelve un Observable Rx que monitoriza los cambios en este RealmObject. Emitirá el RealmObject actual al suscribirse. Por cada actualización del RealmObject, se enviará un par compuesto por el RealmObject y el ObjectChangeSet. El conjunto de cambios será The RealmObject will continually be emitted as it is updated - Los elementos emitidos por Realm Observables están congelados (consulta freeze() ). Esto significa que son inmutables y se pueden leer en cualquier hilo. Realm Observables always emit items from the thread holding the live Realm. This means that if you need to do further processing, it is recommend to observe the values on a computation scheduler: Devuelve Observable de RxJava que solo llama a Throws
|
asFlowable
Returns an RxJava Flowable that monitors changes to this RealmObject. It will emit the current object when subscribed to. Object updates will continuously be emitted as the RealmObject is updated - When chaining a RealmObject observable use Los elementos emitidos desde Realm Flowables están congelados (ver freeze()). Esto significa que son inmutables y se pueden leer en cualquier hilo. Realm Flowables always emit items from the thread holding the live Realm. This means that if you need to do further processing, it is recommend to observe the values on a computation scheduler: If you would like the Parámetros
Devuelve Observable de RxJava que solo llama a Throws
|
public final <any> asFlowable <E >() | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Devuelve un RxJava Flowable que supervisa cambios en este RealmObject. Emitirá el objeto actual cuando se suscriba. Las actualizaciones de los objetos se emitirán continuamente a medida que se actualice el RealmObject - When chaining a RealmObject flowable use Los elementos emitidos desde Realm Flowables están congelados (ver freeze()). Esto significa que son inmutables y se pueden leer en cualquier hilo. Realm Flowables always emit items from the thread holding the live Realm. This means that if you need to do further processing, it is recommend to observe the values on a computation scheduler: If you would like the Type Parameters
Devuelve Observable de RxJava que solo llama a Throws
|
deleteFromRealm
Elimina el objeto del reino con el que está asociado actualmente. Después de llamar a este método, el objeto no será válido y cualquier operación (lectura o escritura) realizada en él fallará con una IllegalStateException. Throws
Tip |
public final void deleteFromRealm () |
|---|
Elimina el objeto del reino al que está asociado actualmente. Después de llamar a este método, el objeto no será válido y cualquier operación (lectura o escritura) realizada en él fallará con una IllegalStateException. Throws
Tip |
freeze
Returns a frozen snapshot of this object. The frozen copy can be read and queried from any thread without throwing an IllegalStateException . La congelación de un RealmObject también crea un Realm congelado que tiene su propio ciclo de vida, pero si el Realm en vivo que generó la colección original se cierra completamente (es decir, todas las instancias de todos los hilos están cerradas), el Realm congelado y el objeto también se cerrarán. Los objetos congelados se pueden consultar de forma normal, pero intentar mutarlos de cualquier forma o intentar registrar un oyente arrojará una IllegalStateException. Nota: Mantener un gran número de objetos congelados con diferentes versiones activas puede tener un impacto negativo en el tamaño del archivo del Realm. Para evitar una situación así, es posible establecer RealmConfiguration.Builder.maxNumberOfActiveVersions(long) . Devuelve una copia congelada de este objeto. Throws
|
public final E freeze <E >() |
|---|
Returns a frozen snapshot of this object. The frozen copy can be read and queried from any thread without throwing an IllegalStateException . La congelación de un RealmObject también crea un Realm congelado que tiene su propio ciclo de vida, pero si el Realm en vivo que generó la colección original se cierra completamente (es decir, todas las instancias de todos los hilos están cerradas), el Realm congelado y el objeto también se cerrarán. Los objetos congelados se pueden consultar de forma normal, pero intentar mutarlos de cualquier forma o intentar registrar un oyente arrojará una IllegalStateException. Nota: Mantener un gran número de objetos congelados con diferentes versiones activas puede tener un impacto negativo en el tamaño del archivo del Realm. Para evitar una situación así, es posible establecer RealmConfiguration.Builder.maxNumberOfActiveVersions(long) . Devuelve una copia congelada de este objeto. Throws
|
getRealm
returns Realm instance where the You must not call Realm.close() against returned instance. Parámetros
Devuelve Realm instance where the Throws
|
Devuelve la instancia Realm a la que pertenece este RealmObject. You must not call Realm.close() against returned instance. Devuelve Instancia de Realm a la que pertenece este objeto o Throws
|
isFrozen
Indica si este RealmObject está congelado o no. Devuelve
Tip |
isLoaded
Checks if the query used to find this RealmObject has completed.Async methods like RealmQuery.findFirstAsync() return an RealmObject that represents the future result of the RealmQuery . It can be considered similar to a java.util.concurrent.Future in this regard. Una vez que "Null" objects represents Synchronous RealmObjects are by definition blocking hence this method will always return Parámetros
Devuelve
|
public final boolean isLoaded () | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Comprueba si la consulta utilizada para encontrar este RealmObject se ha completado. Los métodos asíncronos como RealmQuery.findFirstAsync() devuelven un RealmObject que representa el resultado futuro de la RealmQuery. En este sentido, puede considerarse similar a java.util.concurrent.Future. Una vez que "Null" objects represents Synchronous RealmObjects are by definition blocking hence this method will always return Devuelve
Tip |
esGestionado
Verifica si este objeto es gestionado por Realm. Un objeto gestionado es solo un contenedor alrededor de los datos en el archivo Realm subyacente. En los Looper threads, un objeto gestionado se actualizará en vivo para que siempre apunte a los datos más recientes. Es posible registrar un oyente de cambios usando addChangeListener(RealmModel, RealmChangeListener) para recibir notificaciones cuando ocurran cambios. Los objetos gestionados están confinados a un hilo para que no se pueda acceder a ellos desde otros hilos que no sean el que los creó. Si este método retorna It is possible to create a managed object from an unmanaged object by using Realm.copyToRealm(RealmModel, ImportFlag...) . An unmanaged object can be created from a managed object by using Realm.copyFromRealm(RealmModel) . Devuelve
|
public boolean isManaged () |
|---|
Verifica si este objeto es gestionado por Realm. Un objeto gestionado es solo un contenedor alrededor de los datos en el archivo Realm subyacente. En los Looper threads, un objeto gestionado se actualizará en vivo para que siempre apunte a los datos más recientes. Es posible registrar un observador de cambios utilizando addChangeListener(RealmChangeListener) para recibir notificaciones cuando ocurran cambios. Los objetos gestionados están confinados a un hilo para que no se pueda acceder a ellos desde otros hilos que no sean el que los creó. Si este método retorna It is possible to create a managed object from an unmanaged object by using Realm.copyToRealm(RealmModel, ImportFlag...) . An unmanaged object can be created from a managed object by using Realm.copyFromRealm(RealmModel) . Devuelve
|
isValid
Comprueba si el objeto RealmObject sigue siendo válido, es decir, si no se ha eliminado ni se ha cerrado io.realm.Realm. Siempre devolverá Parámetros
Devuelve
|
public final boolean isValid () | |||
|---|---|---|---|
Comprueba si el objeto RealmObject sigue siendo válido, es decir, si no se ha eliminado ni se ha cerrado io.realm.Realm. Siempre devolverá Note that this can be used to check the validity of certain conditions such as being Devuelve
|
carga
Makes an asynchronous query blocking. This will also trigger any registered listeners.Note: This will return Parámetros
Devuelve
|
public final boolean load () |
|---|
Makes an asynchronous query blocking. This will also trigger any registered listeners.Note: This will return Devuelve
|
removeAllChangeListeners
Removes all registered listeners from the given RealmObject. Parámetros
Throws
|
public final void removeAllChangeListeners () |
|---|
Removes all registered listeners. |
removeChangeListener
Removes a previously registered listener on the given RealmObject. Parámetros
Throws
|
Removes a previously registered listener on the given RealmObject. Parámetros
Throws
|
Removes a previously registered listener. Parámetros
Throws
|
Removes a previously registered listener. Parámetros
Throws
|