public abstract class RealmSchema extends Object
Realm.getSchema() returns an immutable RealmSchema which can only be used for inspecting. Use
DynamicRealm.getSchema() to get a mutable schema.
All changes must happen inside a write transaction for the particular Realm.
RealmMigration| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(String className)
Checks if a given class already exists in the schema.
|
abstract RealmObjectSchema |
create(String className)
Adds a new class to the Realm.
|
abstract RealmObjectSchema |
createWithPrimaryKeyField(String className,
String primaryKeyFieldName,
Class<?> fieldType,
FieldAttribute... attributes)
Adds a new class to the Realm with a primary key field defined.
|
abstract RealmObjectSchema |
get(String className)
Returns the
RealmObjectSchema for a given class. |
abstract Set<RealmObjectSchema> |
getAll()
Returns the
RealmObjectSchemas for all RealmObject classes that can be saved in this Realm. |
abstract void |
remove(String className)
Removes a class from the Realm.
|
abstract RealmObjectSchema |
rename(String oldClassName,
String newClassName)
Renames a class already in the Realm.
|
public abstract RealmObjectSchema get(String className)
RealmObjectSchema for a given class. If this RealmSchema is immutable, an immutable
RealmObjectSchema will be returned. Otherwise, it returns an mutable RealmObjectSchema.className - name of the classnull if the class doesn't exists.public abstract Set<RealmObjectSchema> getAll()
RealmObjectSchemas for all RealmObject classes that can be saved in this Realm. If this
RealmSchema is immutable, an immutable RealmObjectSchema set will be returned. Otherwise, it
returns an mutable RealmObjectSchema set.public abstract RealmObjectSchema create(String className)
className - name of the class.UnsupportedOperationException - if this RealmSchema is immutable.public abstract RealmObjectSchema createWithPrimaryKeyField(String className, String primaryKeyFieldName, Class<?> fieldType, FieldAttribute... attributes)
className - name of the class.primaryKeyFieldName - name of the primary key field.fieldType - type of field to add. Only byte, short, int, long
and their boxed types or the String is supported.attributes - set of attributes for this field. This method implicitly adds
FieldAttribute.PRIMARY_KEY and FieldAttribute.INDEXED attributes to
the field.UnsupportedOperationException - if this RealmSchema is immutable.public abstract void remove(String className)
IllegalStateException. Removes those classes or fields first.className - name of the class to remove.UnsupportedOperationException - if this RealmSchema is immutable.public abstract RealmObjectSchema rename(String oldClassName, String newClassName)
oldClassName - old class name.newClassName - new class name.UnsupportedOperationException - if this RealmSchema is immutable.public boolean contains(String className)
className - class name to check.true if the class already exists. false otherwise.