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 MutableRealmInteger

java.lang.Object
io.realm.MutableRealmInteger

Implemented interfaces:

  • java.lang.Comparable

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 MutableRealmInteger may have the value null .

  • The equals operator compares the contained Long values. null -valued MutableRealmInteger are .equals

  • The compareTo operator compares the contained Long values. It considers null < any non-null value.

  • The increment and decrement operators throw IllegalStateException when applied to a null -valued MutableRealmInteger .

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.

Modificador y Tipo
Método y descripción

public final int

MutableRealmInteger s comparan estrictamente por sus valores.

public abstract void

long dec
)

Decrements the MutableRealmInteger , subtracting the value of the argument.

public final boolean

Dos MutableRealmInteger son .equals si y sólo si sus longValues son iguales.

public abstract Long

get ()

Obtiene el valor MutableRealmInteger.

public final int

A MutableRealmInteger 's hash code is, exactly, the hash code of its value.

public abstract void

long inc
)

Incrementa el/la MutableRealmInteger , sumando el valor del argumento.

public final boolean

public static MutableRealmInteger

Creates a new, unmanaged MutableRealmInteger whose value is null .

public final void

set (
long newValue
)

Sets the MutableRealmInteger value.

public abstract void

set (
Long newValue
)

Sets the MutableRealmInteger value.

public static MutableRealmInteger

String value
)

Crea un nuevo MutableRealmInteger no gestionado con el valor inicial especificado.

public static MutableRealmInteger

long value
)

Crea un nuevo MutableRealmInteger no gestionado con el valor inicial especificado.

public static MutableRealmInteger

Long value
)

Crea un nuevo MutableRealmInteger no gestionado con el valor inicial especificado.

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

public final int compareTo (
)

MutableRealmInteger s compare strictly by their values. Null is a legal value for a MutableRealmInteger and null < any non-null value

Parámetros

  • o - the compare target

Devuelve

-1, 0 o 1, dependiendo de si el valor de este objeto es <, = o > al objetivo.

public abstract void decrement (
long dec
)

Decrements the MutableRealmInteger , subtracting the value of the argument. Increment/decrement from all devices are reflected in the new value, which is guaranteed to converge.

Parámetros

  • dec - cantidad a restar del MutableRealmInteger .

public final boolean equals (
)

Dos MutableRealmInteger son .equals si y sólo si sus longValues son iguales.

Parámetros

  • o - comparar objetivo

Devuelve

verdadero si el objetivo tiene el mismo valor.

Anulaciones

equals en la clase Objeto

public abstract Long get ()

Obtiene el valor MutableRealmInteger. El valor puede ser nulo.

Devuelve

el valor.

public final int hashCode ()

A MutableRealmInteger 's hash code is, exactly, the hash code of its value.

Devuelve

verdadero si el objetivo tiene el mismo valor.

Anulaciones

hashCode en la clase Objeto

public abstract void increment (
long inc
)

Increments the MutableRealmInteger , adding the value of the argument. Increment/decrement from all devices are reflected in the new value, which is guaranteed to converge.

Parámetros

  • inc - cantidad que se añadirá al MutableRealmInteger .

public final boolean isNull ()

Devuelve

verdadero si y solo si obtener devolverá null .

public static MutableRealmInteger ofNull ()

Creates a new, unmanaged MutableRealmInteger whose value is null .

public final void set (
long newValue
)

Establece el valor MutableRealmInteger. Llamar a set establece forzosamente MutableRealmInteger al valor proporcionado. Hacer esto destruye los efectos de cualquier llamada a increment y decrement percibido antes de la llamada a set .

Parámetros

  • newValue - new value.

public abstract void set (
Long newValue
)

Establece el MutableRealmInteger valor.set MutableRealmInteger Llamar a fuerza el establecimiento de al valor proporcionado. Esto elimina los efectos de cualquier llamada a incremento y decremento percibida antes de llamar set a.

Parámetros

  • newValue - new value.

String value
)

Crea un nuevo MutableRealmInteger no gestionado con el valor inicial especificado.

Parámetros

long value
)

Crea un nuevo MutableRealmInteger no gestionado con el valor inicial especificado.

Parámetros

  • value - initial value.

Long value
)

Crea un nuevo MutableRealmInteger no gestionado con el valor inicial especificado.

Parámetros

  • value - initial value.

Volver

Conjunto de cambios de mapas

En esta página