io.realm
Implemented interfaces:
A MutableRealmInteger Es una cantidad numérica mutable, similar a Long. Se comporta casi exactamente como una referencia a Long. Más específicamente:
A
MutableRealmIntegermay have the valuenull.The equals operator compares the contained Long values.
null-valuedMutableRealmIntegerare.equalsThe compareTo operator compares the contained Long values. It considers
null< any non-nullvalue.The increment and decrement operators throw IllegalStateException when applied to a
null-valuedMutableRealmInteger.
MutableRealmInteger Los s son más interesantes como miembros de un objeto RealmModel administrado. Cuando se administran, los operadores de incremento y decremento implementan un
conflict free replicated data type : Simultaneous increments and decrements from multiple distributed clients will be aggregated correctly. For instance, if the value of counter field for the object representing user "Fred" is currently 0, then the following code, executed on two different devices, simultaneously, even if connected by only a slow, unreliable network, will
always cause the value of counter to converge, eventually on the value 2.
MutableRealmInteger counter = realm.where(Users.class) .equalTo("name", Fred) .findFirst() .counter.increment(1);
Tenga en cuenta que el operador set(Long) debe usarse con sumo cuidado. Anulará los efectos de cualquier llamada previa a increment(long) o decrement(long). Aunque el valor de un MutableRealmInteger siempre convergerá entre dispositivos, el valor específico al que converge dependerá del orden real en que se realizaron las operaciones. Por lo tanto, no se recomienda combinar set(Long) con increment(long) y decrement(long), a menos que el conteo difuso sea aceptable.
MutableRealmInteger Los objetos no pueden ser claves primarias. Sus implementaciones no son seguras para subprocesos. Al igual que todos los objetos administrados de Realm, los objetos MutableRealmInteger administrados no pueden moverse entre subprocesos. Los objetos MutableRealmInteger no administrados sí pueden moverse entre subprocesos, pero requieren una publicación segura.
A MutableRealmInteger , in a model class, must always be declared final . For instance:
public final MutableRealmInteger counter = MutableRealmInteger.ofNull();
Although initializing the MutableRealmInteger as null may work very limited circumstances, developers are advised
no hacerlo:
public final MutableRealmInteger counter = null; // DO NOT DO THIS!
Tenga en cuenta también que cuando un MutableRealmInteger es @Required , es mejor, aunque no obligatorio, inicializarlo con un valor distinto de nulo.
@Required public final MutableRealmInteger counter = MutableRealmInteger.valueOf(0L);
A reference to a managed MutableRealmInteger is subject to all of the constraints that apply to the model object from which it was obtained: It can only be mutated within a transaction and it becomes invalid if the Realm backing it is closed. Use the isManaged() and isValid() operators to determine whether a MutableRealmInteger is in a consistent state. Note, in particular, that a reference to a managed MutableRealmInteger retains a reference to the model object to which it belongs. For example in this code:
MutableRealmInteger counter = realm.where(Users.class).findFirst().counter;
the counter holds a reference to the User model object from which it was obtained. Neither can be GCed until all references to both are unreachable.
Resumen del método
Modificador y Tipo | Método y descripción |
|---|---|
public final int |
|
public abstract void | Decrements the |
public final boolean | |
public abstract Long | get () Obtiene el valor |
public final int | hashCode () A |
public abstract void | Incrementa el/la |
public final boolean | isNull () |
public static MutableRealmInteger | ofNull () Creates a new, unmanaged |
public final void | Sets the |
public abstract void | |
public static MutableRealmInteger | |
public static MutableRealmInteger | Crea un nuevo |
public static MutableRealmInteger |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass,hashCode,equals,clone,toString,notify,notifyAll,wait,wait,wait,finalize
Detalle del método
compareTo
Parámetros
Devuelve -1, 0 o 1, dependiendo de si el valor de este objeto es <, = o > al objetivo. |
decremento
Decrements the Parámetros
|
equals
Obtener
hashCode
incremento
Increments the Parámetros
|
isNull
ofNull
public static MutableRealmInteger ofNull () |
|---|
Creates a new, unmanaged |
conjunto
Establece el Parámetros
|
valueOf
Crea un nuevo Parámetros
|
Crea un nuevo Parámetros
|
Crea un nuevo Parámetros
|