Package com.nickbenn.room.model
Class Entity
- java.lang.Object
-
- com.nickbenn.room.model.Entity
-
- All Implemented Interfaces:
Streamable
public class Entity extends Object implements Streamable
Represents an entity in a Room SQLite database schema. This will generally be read from one of the elements of thedatabase.entitiesarray property in a JSON file with the structure described inParser.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDdl()Returns theCREATE TABLESQL statement used to create the SQLite table represented by this instance.List<Index>getIndices()StringgetName()Returns the name of the Room entity (also the SQLite table name) that this instance represents.voidsetDdl(String ddl)Sets theCREATE TABLESQL statement used to create the SQLite table represented by this instance.voidsetIndices(List<Index> indices)voidsetName(String name)Sets the name of the Room entity (also the SQLite table name) that this instance represents.Stream<String>stream()Gathers into aStreamand returns the DDL statements to create the SQLite table corresponding to this instance, along with all of its indices.
-
-
-
Method Detail
-
getName
public String getName()
Returns the name of the Room entity (also the SQLite table name) that this instance represents. This value will generally be read from adatabase.entities[].tableNameproperty in a Room-generated JSON schema file.
-
setName
public void setName(String name)
Sets the name of the Room entity (also the SQLite table name) that this instance represents.- Parameters:
name-
-
getDdl
public String getDdl()
-
setDdl
public void setDdl(String ddl)
Sets theCREATE TABLESQL statement used to create the SQLite table represented by this instance. Ifddlcontains any${TABLE_NAME}placeholders, they'll be included in the value returned bygetDdl(), but not by that returned bystream().- Parameters:
ddl-
-
getIndices
public List<Index> getIndices()
Returns theListofIndexinstances representing the indices declared on this entity, corresponding to the value of thedatabase.entities[].indicesarray property in the JSON schema file. The JSONindiceselements correspond, in turn, to any@Indexelements included in theindicesproperty of an@Entity-annotated class; they also include any indices declared on entity attributes via theindexattribute of the {code ColumnInfo} annotation on a field in an entity class.
-
setIndices
public void setIndices(List<Index> indices)
Sets theListofIndexinstances representing the indices on the table corresponding to this entity.- Parameters:
indices-
-
stream
public Stream<String> stream()
Gathers into aStreamand returns the DDL statements to create the SQLite table corresponding to this instance, along with all of its indices. As part of this process, all${TABLE_NAME}placeholders in the DDL are replaced by the value returned bygetName().- Specified by:
streamin interfaceStreamable
-
-