public 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(Object o) |
<E> E |
get(String fieldName)
Returns the value for the given field.
|
byte[] |
getBlob(String fieldName)
Returns the
byte[] value for a given field. |
boolean |
getBoolean(String fieldName)
Returns the
boolean value for a given field. |
byte |
getByte(String fieldName)
Returns the
byte value for a given field. |
Date |
getDate(String fieldName)
Returns the
Date value for a given field. |
double |
getDouble(String fieldName)
Returns the
double value for a given field. |
DynamicRealm |
getDynamicRealm()
Returns
DynamicRealm instance where this DynamicRealmObject belongs. |
String[] |
getFieldNames()
Returns the list of field names on this object.
|
RealmFieldType |
getFieldType(String fieldName)
Returns the type used by the underlying storage engine to represent this field.
|
float |
getFloat(String fieldName)
Returns the
float value for a given field. |
int |
getInt(String fieldName)
Returns the
int value for a given field. |
RealmList<DynamicRealmObject> |
getList(String fieldName)
Returns the
RealmList of DynamicRealmObjects being linked from the given field. |
<E> RealmList<E> |
getList(String fieldName,
Class<E> primitiveType)
Returns the
RealmList containing only primitive values. |
long |
getLong(String fieldName)
Returns the
long value for a given field. |
DynamicRealmObject |
getObject(String fieldName)
Returns the object being linked to from this field.
|
short |
getShort(String fieldName)
Returns the
short value for a given field. |
String |
getString(String fieldName)
Returns the
String value for a given field. |
String |
getType()
Returns the type of object.
|
boolean |
hasField(String fieldName)
Checks whether an object has the given field or not.
|
int |
hashCode()
Returns a hash code value for the
DynamicRealmObject object. |
boolean |
isNull(String fieldName)
Checks if the value of a given field is
null. |
RealmResults<DynamicRealmObject> |
linkingObjects(String srcClassName,
String srcFieldName)
Returns
RealmResults containing all srcClassName class objects that have a relationship
to this object from srcFieldName field. |
void |
realm$injectObjectContext() |
ProxyState |
realmGet$proxyState() |
void |
set(String fieldName,
Object value)
Sets the value for the given field.
|
void |
setBlob(String fieldName,
byte[] value)
Sets the binary value of the given field.
|
void |
setBoolean(String fieldName,
boolean value)
Sets the
boolean value of the given field. |
void |
setByte(String fieldName,
byte value)
Sets the
byte value of the given field. |
void |
setDate(String fieldName,
Date value)
Sets the
Date value of the given field. |
void |
setDouble(String fieldName,
double value)
Sets the
double value of the given field. |
void |
setFloat(String fieldName,
float value)
Sets the
float value of the given field. |
void |
setInt(String fieldName,
int value)
Sets the
int value of the given field. |
<E> void |
setList(String fieldName,
RealmList<E> list)
Sets the reference to a
RealmList on the given field. |
void |
setLong(String fieldName,
long value)
Sets the
long value of the given field. |
void |
setNull(String fieldName)
Sets the value to
null for the given field. |
void |
setObject(String fieldName,
DynamicRealmObject value)
Sets a reference to another object on the given field.
|
void |
setShort(String fieldName,
short value)
Sets the
short value of the given field. |
void |
setString(String fieldName,
String value)
Sets the
String value of the given field. |
String |
toString() |
addChangeListener, addChangeListener, addChangeListener, addChangeListener, asChangesetObservable, asChangesetObservable, asFlowable, asFlowable, deleteFromRealm, deleteFromRealm, getRealm, getRealm, isLoaded, isLoaded, isManaged, isManaged, isValid, isValid, load, load, removeAllChangeListeners, removeAllChangeListeners, removeChangeListener, removeChangeListener, removeChangeListener, removeChangeListenerpublic DynamicRealmObject(RealmModel obj)
obj - the Realm object to convert to a dynamic object. Only objects managed by Realm can be used.IllegalArgumentException - if object isn't managed by Realm or is a DynamicRealmObject already.public <E> E get(String fieldName)
fieldName - name of the field.ClassCastException - if the field doesn't contain a field of the defined return type.public boolean getBoolean(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.IllegalArgumentException - if field name doesn't exist or it doesn't contain booleans.RealmException - if the return value would be null.public int getInt(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.IllegalArgumentException - if field name doesn't exist or it doesn't contain integers.RealmException - if the return value would be null.public short getShort(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.IllegalArgumentException - if field name doesn't exist or it doesn't contain integers.RealmException - if the return value would be null.public long getLong(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.IllegalArgumentException - if field name doesn't exist or it doesn't contain integers.RealmException - if the return value would be null.public byte getByte(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.IllegalArgumentException - if field name doesn't exist or it doesn't contain integers.RealmException - if the return value would be null.public float getFloat(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.IllegalArgumentException - if field name doesn't exist or it doesn't contain floats.RealmException - if the return value would be null.public double getDouble(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.IllegalArgumentException - if field name doesn't exist or it doesn't contain doubles.RealmException - if the return value would be null.public byte[] getBlob(String fieldName)
byte[] value for a given field.fieldName - the name of the field.IllegalArgumentException - if field name doesn't exist or it doesn't contain binary data.public String getString(String fieldName)
String value for a given field.fieldName - the name of the field.IllegalArgumentException - if field name doesn't exist or it doesn't contain Strings.public Date getDate(String fieldName)
Date value for a given field.fieldName - the name of the field.IllegalArgumentException - if field name doesn't exist or it doesn't contain Dates.public DynamicRealmObject getObject(String fieldName)
fieldName - the name of the field.DynamicRealmObject representation of the linked object or null if no object is linked.IllegalArgumentException - if field name doesn't exist or it doesn't contain links to other objects.public RealmList<DynamicRealmObject> getList(String fieldName)
RealmList of DynamicRealmObjects being linked from the given field.
If the list contains primitive types, use getList(String, Class) instead.
fieldName - the name of the field.RealmList data for this field.IllegalArgumentException - if field name doesn't exist or it doesn't contain a list of objects.public <E> RealmList<E> getList(String fieldName, Class<E> primitiveType)
RealmList containing only primitive values.
If the list contains references to other Realm objects, use getList(String) instead.
fieldName - the name of the field.primitiveType - the type of elements in the list. Only primitive types are supported.RealmList data for this field.IllegalArgumentException - if field name doesn't exist or it doesn't contain a list of primitive objects.public boolean isNull(String fieldName)
null.fieldName - the name of the field.true if field value is null, false otherwise.IllegalArgumentException - if field name doesn't exist.public boolean hasField(String fieldName)
fieldName - field name to check.true if the object has a field with the given name, false otherwise.public String[] getFieldNames()
public void set(String fieldName, Object value)
String to their appropriate type. For example "10"
will be converted to 10 if the field type is int.
Using the typed setters will be faster than using this method.
IllegalArgumentException - if field name doesn't exist or if the input value cannot be converted
to the appropriate input type.NumberFormatException - if a String based number cannot be converted properly.RealmException - if the field is a PrimaryKey field.public void setBoolean(String fieldName, boolean value)
boolean value of the given field.fieldName - field name to update.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't a boolean field.public void setShort(String fieldName, short value)
short value of the given field.fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't an integer field.RealmException - if the field is a PrimaryKey field.public void setInt(String fieldName, int value)
int value of the given field.fieldName - field name to update.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't an integer field.RealmException - if the field is a PrimaryKey field.public void setLong(String fieldName, long value)
long value of the given field.fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't an integer field.RealmException - if the field is a PrimaryKey field.public void setByte(String fieldName, byte value)
byte value of the given field.fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't an integer field.RealmException - if the field is a PrimaryKey field.public void setFloat(String fieldName, float value)
float value of the given field.fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't a float field.public void setDouble(String fieldName, double value)
double value of the given field.fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't a double field.public void setString(String fieldName, String value)
String value of the given field.fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't a String field.RealmException - if the field is a PrimaryKey field.public void setBlob(String fieldName, byte[] value)
fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't a binary field.public void setDate(String fieldName, Date value)
Date value of the given field.fieldName - field name.value - value to insert.IllegalArgumentException - if field name doesn't exist or field isn't a Date field.public void setObject(String fieldName, DynamicRealmObject value)
fieldName - field name.value - object to link to.IllegalArgumentException - if field name doesn't exist, it doesn't link to other Realm objects, the type
of DynamicRealmObject doesn't match or it belongs to a different Realm.public <E> void setList(String fieldName, RealmList<E> list)
RealmList on the given field.
This will copy all the elements in the list into Realm, but any further changes to the list
will not be reflected in the Realm. Use getList(String) in order to get a reference to
the managed list.
fieldName - field name.list - list of objects. Must either be primitive types or DynamicRealmObjects.IllegalArgumentException - if field name doesn't exist, it is not a list field, the objects in the
list doesn't match the expected type or any Realm object in the list belongs to a different Realm.public void setNull(String fieldName)
null for the given field.fieldName - field name.IllegalArgumentException - if field name doesn't exist, or the field isn't nullable.RealmException - if the field is a PrimaryKey field.public String getType()
RealmObject.public RealmFieldType getFieldType(String fieldName)
public int hashCode()
DynamicRealmObject object.
By the general contract of Object.hashCode(), any two objects for which equals(java.lang.Object)
returns true must return the same hash code value.
Note that a RealmObject is a live object, and it might be updated by changes from
other threads. This means that a hash code value of the object is not stable, and the value
should be neither used as a key in HashMap nor saved in HashSet.
hashCode in class Objectequals(java.lang.Object)public RealmResults<DynamicRealmObject> linkingObjects(String srcClassName, String srcFieldName)
RealmResults containing all srcClassName class objects that have a relationship
to this object from srcFieldName field.
An entry is added for each reference, e.g. if the same reference is in a list multiple times, the src object will show up here multiple times.
srcClassName - name of the class returned objects belong to.srcFieldName - name of the field in the source class that holds a reference to this object.
Field type must be either io.realm.RealmFieldType.OBJECT or io.realm.RealmFieldType.LIST.IllegalArgumentException - if the srcClassName is null or does not exist,
the srcFieldName is null or does not exist,
type of the source field is not supported.public DynamicRealm getDynamicRealm()
DynamicRealm instance where this DynamicRealmObject belongs.
You must not call BaseRealm.close() against returned instance.
DynamicRealm instance where this object belongs.IllegalStateException - if this object was deleted or the corresponding DynamicRealm was already closed.public void realm$injectObjectContext()
public ProxyState realmGet$proxyState()