Package onl.ycode.stormify
Class TableInfo
java.lang.Object
onl.ycode.stormify.TableInfo
Parse a class and handle it as a database table.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check the consistency of the table.Class<?>
Get the class type of the table.getDbField
(String name) Get a reference of the field, given a specific database column name.Get a reference of the field, given a specific field name.Get a reference of the fields of the table.Get the primary key of the table.Get a list of all primary keys of the table.Get the name of the table.toString()
-
Method Details
-
getClassType
Get the class type of the table.- Returns:
- The class type of the table.
-
getTableName
Get the name of the table.- Returns:
- The name of the table.
-
getPrimaryKeys
Get a list of all primary keys of the table.- Returns:
- The primary keys of the table.
-
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
Get a reference of the fields of the table.- Returns:
- The fields of the table.
-
getDbField
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
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
-
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.
-