public final class DynamicRealmObject extends RealmObject
Constructor and Description |
---|
DynamicRealmObject(RealmModel obj)
Creates a dynamic Realm object based on an existing object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
<E> E |
get(java.lang.String fieldName)
Returns the value for the given field.
|
byte[] |
getBlob(java.lang.String fieldName)
Returns the
byte[] value for a given field. |
boolean |
getBoolean(java.lang.String fieldName)
Returns the
boolean value for a given field. |
byte |
getByte(java.lang.String fieldName)
Returns the
byte value for a given field. |
java.util.Date |
getDate(java.lang.String fieldName)
Returns the
Date value for a given field. |
double |
getDouble(java.lang.String fieldName)
Returns the
double value for a given field. |
java.lang.String[] |
getFieldNames()
Returns the list of field names on this object.
|
RealmFieldType |
getFieldType(java.lang.String fieldName)
Returns the type used by the underlying storage engine to represent this field.
|
float |
getFloat(java.lang.String fieldName)
Returns the
float value for a given field. |
int |
getInt(java.lang.String fieldName)
Returns the
int value for a given field. |
RealmList<DynamicRealmObject> |
getList(java.lang.String fieldName)
Returns the
RealmList of objects being linked to from this field. |
long |
getLong(java.lang.String fieldName)
Returns the
long value for a given field. |
DynamicRealmObject |
getObject(java.lang.String fieldName)
Returns the object being linked to from this field.
|
short |
getShort(java.lang.String fieldName)
Returns the
short value for a given field. |
java.lang.String |
getString(java.lang.String fieldName)
Returns the
String value for a given field. |
java.lang.String |
getType()
Return the type of object.
|
boolean |
hasField(java.lang.String fieldName)
Checks whether an object has the given field or not.
|
int |
hashCode() |
boolean |
isNull(java.lang.String fieldName)
Checks if the value of a given field is
null . |
ProxyState |
realmGet$proxyState() |
void |
set(java.lang.String fieldName,
java.lang.Object value)
Set the value for the given field.
|
void |
setBlob(java.lang.String fieldName,
byte[] value)
Sets the binary value of the given field.
|
void |
setBoolean(java.lang.String fieldName,
boolean value)
Sets the
boolean value of the given field. |
void |
setByte(java.lang.String fieldName,
byte value)
Sets the
byte value of the given field. |
void |
setDate(java.lang.String fieldName,
java.util.Date value)
Sets the
Date value of the given field. |
void |
setDouble(java.lang.String fieldName,
double value)
Sets the
double value of the given field. |
void |
setFloat(java.lang.String fieldName,
float value)
Sets the
float value of the given field. |
void |
setInt(java.lang.String fieldName,
int value)
Sets the
int value of the given field. |
void |
setList(java.lang.String fieldName,
RealmList<? extends RealmModel> list)
Sets the reference to a
RealmList on the given field. |
void |
setLong(java.lang.String fieldName,
long value)
Sets the
long value of the given field. |
void |
setNull(java.lang.String fieldName)
Sets the value to
null for the given field. |
void |
setObject(java.lang.String fieldName,
DynamicRealmObject value)
Sets a reference to another object on the given field.
|
void |
setShort(java.lang.String fieldName,
short value)
Sets the
short value of the given field. |
void |
setString(java.lang.String fieldName,
java.lang.String value)
Sets the
String value of the given field. |
java.lang.String |
toString() |
addChangeListener, addChangeListener, asObservable, asObservable, deleteFromRealm, deleteFromRealm, isLoaded, isLoaded, isValid, isValid, load, load, removeChangeListener, removeChangeListener, removeChangeListeners, removeChangeListeners, removeFromRealm
public DynamicRealmObject(RealmModel obj)
obj
- the Realm object to convert to a dynamic object. Only objects managed by Realm
can be used.java.lang.IllegalArgumentException
- if object isn't managed by Realm or is a DynamicRealmObject
already.public <E> E get(java.lang.String fieldName)
fieldName
- name of the field.java.lang.ClassCastException
- if the field doesn't contain a field of the defined return type.public boolean getBoolean(java.lang.String fieldName)
boolean
value for a given field.
If the field is nullable use isNull(String)
to check for null
instead of using
this method.fieldName
- the name of the field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain booleans.RealmException
- if the return value would be null
.public int getInt(java.lang.String fieldName)
int
value for a given field.
If the field is nullable use isNull(String)
to check for null
instead of using
this method.fieldName
- the name of the field.Integer.MAX_VALUE
will wrap.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.RealmException
- if the return value would be null
.public short getShort(java.lang.String fieldName)
short
value for a given field.
If the field is nullable use isNull(String)
to check for null
instead of using
this method.fieldName
- the name of the field.Short.MAX_VALUE
will wrap.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.RealmException
- if the return value would be null
.public long getLong(java.lang.String fieldName)
long
value for a given field.
If the field is nullable use isNull(String)
to check for null
instead of using
this method.fieldName
- the name of the field.Long.MAX_VALUE
will wrap.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.RealmException
- if the return value would be null
.public byte getByte(java.lang.String fieldName)
byte
value for a given field.
If the field is nullable use isNull(String)
to check for null
instead of using
this method.fieldName
- the name of the field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.RealmException
- if the return value would be null
.public float getFloat(java.lang.String fieldName)
float
value for a given field.
If the field is nullable use isNull(String)
to check for null
instead of using
this method.fieldName
- the name of the field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain floats.RealmException
- if the return value would be null
.public double getDouble(java.lang.String fieldName)
double
value for a given field.
If the field is nullable use isNull(String)
to check for null
instead of using
this method.fieldName
- the name of the field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain doubles.RealmException
- if the return value would be null
.public byte[] getBlob(java.lang.String fieldName)
byte[]
value for a given field.fieldName
- the name of the field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain binary data.public java.lang.String getString(java.lang.String fieldName)
String
value for a given field.fieldName
- the name of the field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain Strings.public java.util.Date getDate(java.lang.String fieldName)
Date
value for a given field.fieldName
- the name of the field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain Dates.public DynamicRealmObject getObject(java.lang.String fieldName)
fieldName
- the name of the field.DynamicRealmObject
representation of the linked object or null
if no object is linked.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain links to other objects.public RealmList<DynamicRealmObject> getList(java.lang.String fieldName)
RealmList
of objects being linked to from this field.fieldName
- the name of the field.RealmList
data for this field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain a list of links.public boolean isNull(java.lang.String fieldName)
null
.fieldName
- the name of the field.true
if field value is null, false
otherwise.java.lang.IllegalArgumentException
- if field name doesn't exists.public boolean hasField(java.lang.String fieldName)
fieldName
- field name to check.true
if the object has a field with the given name, false
otherwise.public java.lang.String[] getFieldNames()
public void set(java.lang.String fieldName, java.lang.Object value)
String
to their appropriate type. E.g. "10"
will be
converted to 10
if the field type is int
.
Using the typed setters will be faster than using this method.java.lang.IllegalArgumentException
- if field name doesn't exists or if the input value cannot be converted
to the appropriate input type.java.lang.NumberFormatException
- if a String based number cannot be converted properly.public void setBoolean(java.lang.String fieldName, boolean value)
boolean
value of the given field.fieldName
- field name to update.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a boolean field.public void setShort(java.lang.String fieldName, short value)
short
value of the given field.fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setInt(java.lang.String fieldName, int value)
int
value of the given field.fieldName
- field name to update.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setLong(java.lang.String fieldName, long value)
long
value of the given field.fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setByte(java.lang.String fieldName, byte value)
byte
value of the given field.fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setFloat(java.lang.String fieldName, float value)
float
value of the given field.fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setDouble(java.lang.String fieldName, double value)
double
value of the given field.fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a double field.public void setString(java.lang.String fieldName, java.lang.String value)
String
value of the given field.fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a String field.public void setBlob(java.lang.String fieldName, byte[] value)
fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a binary field.public void setDate(java.lang.String fieldName, java.util.Date value)
Date
value of the given field.fieldName
- field name.value
- value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a Date field.public void setObject(java.lang.String fieldName, DynamicRealmObject value)
fieldName
- field name.value
- object to link to.java.lang.IllegalArgumentException
- if field name doesn't exists, it doesn't link to other Realm objects, the type
of DynamicRealmObject doesn't match or it belongs to a different Realm.public void setList(java.lang.String fieldName, RealmList<? extends RealmModel> list)
RealmList
on the given field.fieldName
- field name.list
- list of references.java.lang.IllegalArgumentException
- if field name doesn't exist, it is not a list field, the type
of the object represented by the DynamicRealmObject doesn't match or any element in the list belongs to a
different Realm.public void setNull(java.lang.String fieldName)
null
for the given field.fieldName
- field name.java.lang.IllegalArgumentException
- if field name doesn't exists, or the field isn't nullable.public java.lang.String getType()
RealmObject
.public RealmFieldType getFieldType(java.lang.String fieldName)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public ProxyState realmGet$proxyState()