Class RealmObjectSchema
On this page
- io.realm
- Nested Class Summary
- Method Summary
- Inherited Methods
- Method Detail
- addField
- addIndex
- addPrimaryKey
- addRealmDictionaryField
- addRealmListField
- addRealmObjectField
- addRealmSetField
- getClassName
- getFieldNames
- getFieldType
- getPrimaryKey
- hasField
- hasIndex
- hasPrimaryKey
- isEmbedded
- isNullable
- isPrimaryKey
- isRequired
- removeField
- removeIndex
- removePrimaryKey
- renameField
- setClassName
- setEmbedded
- setNullable
- setRequired
- transform
io.realm
Class for interacting with the schema for a given RealmObject class. This makes it possible to inspect, add, delete or change the fields for given class.If this RealmObjectSchema is retrieved from an immutable RealmSchema , this RealmObjectSchema will be immutable as well.
Nested Class Summary
Modifier and Type | Class and Description |
---|---|
public static interface |
Method Summary
Modifier and Type | Method and Description |
---|---|
public abstract RealmObjectSchema | Adds a new simple field to the RealmObject class. |
public abstract RealmObjectSchema | |
public abstract RealmObjectSchema | Adds a primary key to a given field. |
public abstract RealmObjectSchema | Adds a new field that references a RealmDictionary with primitive values. |
public abstract RealmObjectSchema | Adds a new field that contains a RealmDictionary with references to other Realm model classes. |
public abstract RealmObjectSchema | Adds a new field that references a RealmList with primitive values. |
public abstract RealmObjectSchema | Adds a new field that contains a RealmList with references to other Realm model classes. |
public abstract RealmObjectSchema | Adds a new field that references another RealmObject . |
public abstract RealmObjectSchema | Adds a new field that references a RealmSet with primitive values. |
public abstract RealmObjectSchema | Adds a new field that contains a RealmSet with references to other Realm model classes. |
public String | getClassName () Returns the name of the RealmObject class being represented by this schema. |
public Set | Returns all fields in this class. |
public RealmFieldType | Returns the type used by the underlying storage engine to represent this field. |
public String | Returns the name of the primary key field. |
public boolean | |
public boolean | |
public boolean | Checks if the class has a primary key defined. |
public boolean | isEmbedded () Returns |
public boolean | Checks if a given field is nullable i.e., it is allowed to contain |
public boolean | Checks if a given field is the primary key field. |
public boolean | Checks if a given field is required i.e., it is not allowed to contain |
public abstract RealmObjectSchema | Removes a field from the class. |
public abstract RealmObjectSchema | Removes an index from a given field. |
public abstract RealmObjectSchema | Removes the primary key from this class. |
public abstract RealmObjectSchema | Renames a field from one name to another. |
public abstract RealmObjectSchema | Sets a new name for this RealmObject class. |
public void | Converts the class to be embedded or not. |
public abstract RealmObjectSchema | Sets a field to be nullable i.e., it should be able to hold |
public abstract RealmObjectSchema | Sets a field to be required i.e., it is not allowed to hold |
public abstract RealmObjectSchema | Runs a transformation function on each RealmObject instance of the current class. |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Method Detail
addField
public abstract RealmObjectSchema addField ( ) |
---|
Adds a new simple field to the RealmObject class. The type must be one supported by Realm. See RealmObject for the list of supported types. If the field should allow To add fields that reference other RealmObjects or RealmLists use addRealmObjectField(String, RealmObjectSchema) or addRealmListField(String, RealmObjectSchema) instead. Parameters
Returns the updated schema. Throws
|
addIndex
Adds an index to a given field. This is the equivalent of adding the io.realm.annotations.Index annotation on the field. Parameters
Returns the updated schema. Throws
|
addPrimaryKey
Adds a primary key to a given field. This is the same as adding the io.realm.annotations.PrimaryKey annotation on the field. Further, this implicitly adds io.realm.annotations.Index annotation to the field as well. Parameters
Returns the updated schema. Throws
|
addRealmDictionaryField
public abstract RealmObjectSchema addRealmDictionaryField ( String fieldName, java.lang.Class<?> primitiveType ) | ||||
---|---|---|---|---|
Adds a new field that references a RealmDictionary with primitive values. See RealmObject for the list of supported types. Nullability of elements are defined by using the correct class e.g., Example:
If the list contains references to other Realm classes, use addRealmDictionaryField(String, RealmObjectSchema) instead. Parameters
Returns the updated schema. Throws
|
public abstract RealmObjectSchema addRealmDictionaryField ( String fieldName, RealmObjectSchema objectSchema ) |
---|
Adds a new field that contains a RealmDictionary with references to other Realm model classes. If the dictionary contains primitive types, use addRealmDictionaryField(String, Class) instead. Parameters
Returns the updated schema. Throws
|
addRealmListField
public abstract RealmObjectSchema addRealmListField ( String fieldName, java.lang.Class<?> primitiveType ) | ||||
---|---|---|---|---|
Adds a new field that references a RealmList with primitive values. See RealmObject for the list of supported types. Nullability of elements are defined by using the correct class e.g., Example:
If the list contains references to other Realm classes, use addRealmListField(String, RealmObjectSchema) instead. Parameters
Returns the updated schema. Throws
|
public abstract RealmObjectSchema addRealmListField ( String fieldName, RealmObjectSchema objectSchema ) |
---|
Adds a new field that contains a RealmList with references to other Realm model classes. If the list contains primitive types, use addRealmListField(String, Class) instead. Parameters
Returns the updated schema. Throws
|
addRealmObjectField
public abstract RealmObjectSchema addRealmObjectField ( String fieldName, RealmObjectSchema objectSchema ) |
---|
Adds a new field that references another RealmObject . Parameters
Returns the updated schema. Throws
|
addRealmSetField
public abstract RealmObjectSchema addRealmSetField ( String fieldName, java.lang.Class<?> primitiveType ) | ||||
---|---|---|---|---|
Adds a new field that references a RealmSet with primitive values. See RealmObject for the list of supported types. Nullability of elements are defined by using the correct class e.g., Example:
If the list contains references to other Realm classes, use addRealmSetField(String, RealmObjectSchema) instead. Parameters
Returns the updated schema. Throws
|
public abstract RealmObjectSchema addRealmSetField ( String fieldName, RealmObjectSchema objectSchema ) |
---|
Adds a new field that contains a RealmSet with references to other Realm model classes. If the set contains primitive types, use addRealmSetField(String, Class) instead. Parameters
Returns the updated schema. Throws
|
getClassName
public String getClassName () |
---|
Returns the name of the RealmObject class being represented by this schema.
Returns the name of the RealmObject class represented by this schema. Throws
|
getFieldNames
public Set getFieldNames () |
---|
Returns all fields in this class. Returns a list of all the fields in this class. |
getFieldType
Returns the type used by the underlying storage engine to represent this field. Parameters
Returns the underlying type used by Realm to represent this field. |
getPrimaryKey
public String getPrimaryKey () |
---|
Returns the name of the primary key field. Returns the name of the primary key field. Throws
|
hasField
hasIndex
Checks if a given field has an index defined. Parameters
Returns
Throws
|
hasPrimaryKey
public boolean hasPrimaryKey () |
---|
Checks if the class has a primary key defined. Returns
|
isEmbedded
public boolean isEmbedded () |
---|
Returns Returns
|
isNullable
Checks if a given field is nullable i.e., it is allowed to contain Parameters
Returns
Throws
|
isPrimaryKey
Checks if a given field is the primary key field. Parameters
Returns
Throws
|
isRequired
Checks if a given field is required i.e., it is not allowed to contain Parameters
Returns
Throws
|
removeField
Removes a field from the class. Parameters
Returns the updated schema. Throws
|
removeIndex
Removes an index from a given field. This is the same as removing the Parameters
Returns the updated schema. Throws
|
removePrimaryKey
public abstract RealmObjectSchema removePrimaryKey () |
---|
Removes the primary key from this class. This is the same as removing the io.realm.annotations.PrimaryKey annotation from the class. Further, this implicitly removes io.realm.annotations.Index annotation from the field as well. Returns the updated schema. Throws
|
renameField
Renames a field from one name to another. Parameters
Returns the updated schema. Throws
|
setClassName
Sets a new name for this RealmObject class. This is equivalent to renaming it. Parameters
Throws
|
setEmbedded
Converts the class to be embedded or not.A class can only be marked as embedded if the following invariants are satisfied:
Throws
|
setNullable
Sets a field to be nullable i.e., it should be able to hold If the type of designated field is a list of values (not RealmObject s , specified nullability only affects its elements, not the field itself. Value list itself is always non-nullable. Parameters
Returns the updated schema. Throws
|
setRequired
Sets a field to be required i.e., it is not allowed to hold If the type of designated field is a list of values (not RealmObject s , specified nullability only affects its elements, not the field itself. Value list itself is always non-nullable. Parameters
Returns the updated schema. Throws
|
transform
Runs a transformation function on each RealmObject instance of the current class. The object will be represented as a DynamicRealmObject . There is no guarantees in which order the objects are returned. Parameters
Returns this schema. Throws
|