Class 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 the database.entities array property in a JSON file with the structure described in Parser.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String getDdl()
      Returns the CREATE TABLE SQL statement used to create the SQLite table represented by this instance.
      List<Index> getIndices()
      Returns the List of Index instances representing the indices declared on this entity, corresponding to the value of the database.entities[].indices array property in the JSON schema file.
      String getName()
      Returns the name of the Room entity (also the SQLite table name) that this instance represents.
      void setDdl​(String ddl)
      Sets the CREATE TABLE SQL statement used to create the SQLite table represented by this instance.
      void setIndices​(List<Index> indices)
      Sets the List of Index instances representing the indices on the table corresponding to this entity.
      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 a Stream 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 a database.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()
        Returns the CREATE TABLE SQL statement used to create the SQLite table represented by this instance. Note that the return value of this method includes a ${TABLE_NAME} placeholder; the stream() method replaces the placeholder with the value returned by getName().
      • setDdl

        public void setDdl​(String ddl)
        Sets the CREATE TABLE SQL statement used to create the SQLite table represented by this instance. If ddl contains any ${TABLE_NAME} placeholders, they'll be included in the value returned by getDdl(), but not by that returned by stream().
        Parameters:
        ddl -
      • getIndices

        public List<Index> getIndices()
        Returns the List of Index instances representing the indices declared on this entity, corresponding to the value of the database.entities[].indices array property in the JSON schema file. The JSON indices elements correspond, in turn, to any @Index elements included in the indices property of an @Entity-annotated class; they also include any indices declared on entity attributes via the index attribute of the {code ColumnInfo} annotation on a field in an entity class.
      • setIndices

        public void setIndices​(List<Index> indices)
        Sets the List of Index instances representing the indices on the table corresponding to this entity.
        Parameters:
        indices -
      • stream

        public Stream<String> stream()
        Gathers into a Stream 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 by getName().
        Specified by:
        stream in interface Streamable