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.entities
array property in a JSON file with the structure described inParser
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDdl()
Returns theCREATE TABLE
SQL statement used to create the SQLite table represented by this instance.List<Index>
getIndices()
String
getName()
Returns the name of the Room entity (also the SQLite table name) that this instance represents.void
setDdl(String ddl)
Sets theCREATE TABLE
SQL statement used to create the SQLite table represented by this instance.void
setIndices(List<Index> indices)
void
setName(String name)
Sets the name of the Room entity (also the SQLite table name) that this instance represents.Stream<String>
stream()
Gathers into aStream
and 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[].tableName
property 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 TABLE
SQL statement used to create the SQLite table represented by this instance. Ifddl
contains 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 theList
ofIndex
instances representing the indices declared on this entity, corresponding to the value of thedatabase.entities[].indices
array property in the JSON schema file. The JSONindices
elements correspond, in turn, to any@Index
elements included in theindices
property of an@Entity
-annotated class; they also include any indices declared on entity attributes via theindex
attribute of the {code ColumnInfo} annotation on a field in an entity class.
-
setIndices
public void setIndices(List<Index> indices)
Sets theList
ofIndex
instances representing the indices on the table corresponding to this entity.- Parameters:
indices
-
-
stream
public Stream<String> stream()
Gathers into aStream
and 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:
stream
in interfaceStreamable
-
-