Class TableInfo

java.lang.Object
onl.ycode.stormify.TableInfo

public class TableInfo extends Object
Parse a class and handle it as a database table.
  • Method Details

    • getClassType

      public Class<?> getClassType()
      Get the class type of the table.
      Returns:
      The class type of the table.
    • getTableName

      public String getTableName()
      Get the name of the table.
      Returns:
      The name of the table.
    • getPrimaryKeys

      public List<FieldInfo> getPrimaryKeys()
      Get a list of all primary keys of the table.
      Returns:
      The primary keys of the table.
    • getPrimaryKey

      public FieldInfo getPrimaryKey()
      Get the primary key of the table. If the table has more than one primary key, or no primary key, then an exception is thrown.
      Returns:
      The primary key of the table.
    • getFields

      public Collection<FieldInfo> getFields()
      Get a reference of the fields of the table.
      Returns:
      The fields of the table.
    • getDbField

      public Collection<FieldInfo> getDbField(String name)
      Get a reference of the field, given a specific database column name.

      Note that there may be more than one FieldInfo, to support cases where the same column is used in multiple fields. One such common scenario is when a foreign key is used both as a reference and as a numeric id value.

      Parameters:
      name - The name of the column in the database.
      Returns:
      The fields corresponding to the specific column name.
    • getField

      public FieldInfo getField(String name)
      Get a reference of the field, given a specific field name.
      Parameters:
      name - The name of the field, as a Java property.
      Returns:
      The field corresponding to the specific field name.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • checkConsistency

      public boolean checkConsistency()
      Check the consistency of the table. For every database column, there should be at most one field that is updatable and at most one field that is creatable. If there are more than one fields, then the table is considered inconsistent.
      Returns:
      True if the table is consistent, false otherwise.