Package no.sikt.graphitron.mappings
Class TableReflection
java.lang.Object
no.sikt.graphitron.mappings.TableReflection
Helper class that takes care of any table reflection operations the code generator might require towards the jOOQ source.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfieldIsNullable(String tableName, String fieldName) static booleanfieldTypeIsCLOB(String table, String name) findImplicitKey(String leftTableName, String rightTableName) getClassFromSchemas(String className) static Optional<org.jooq.Field<?>>getFieldType(String table, String name) static Optional<org.jooq.ForeignKey<?,?>> getForeignKey(String name) getForeignKeysBetweenTables(String leftTableName, String rightTableName) static Optional<org.jooq.Index>getJavaFieldName(String tableName, String fieldName) getJavaFieldNamesForKey(String tableName, org.jooq.Key<?> key) getJavaFieldNamesForTable(String tableName) getKeyFields(JOOQMapping key) getKeySourceTable(String keyName) getKeyTargetTable(String keyName) getMethodFromReference(String reference, String tableName, String methodName) static intgetNumberOfForeignKeysBetweenTables(String leftTableName, String rightTableName) static Optional<? extends org.jooq.UniqueKey<?>>getPrimaryKeyForTable(String tableName) static Optional<? extends org.jooq.UniqueKey<?>>getPrimaryOrUniqueKeyMatchingFields(String table, List<String> fields) getRecordClass(String name) getRequiredFields(String tableName) static Optional<org.jooq.Table<?>>getTableClass(String name) static booleanhasSelfRelation(String tableName) static TableRelationTypeinferRelationType(String leftTableName, String rightTableName, JOOQMapping preferredKey) static booleanstatic booleanrecordUsesFSHack(String tableName) NEW FS hack!searchTableForKeyMethodName(String tableName, String keyName) Search this jOOQ table for a path method that matches the provided key name.searchTableForMethodWithName(String tableName, String name) Search this jOOQ table for a method that matches this name.static booleantableExists(String tableName) static booleantableFieldHasDefaultValue(String tableName, String fieldName) static booleantableHasIndex(String tableName, String indexName) Checks if a table has an index with the specified name.static booleantableHasPrimaryKey(String tableName) static booleantableOrKeyExists(String name)
-
Constructor Details
-
TableReflection
public TableReflection()
-
-
Method Details
-
findImplicitKey
- Returns:
- The implicit key between these two tables.
-
getForeignKeysBetweenTables
-
getNumberOfForeignKeysBetweenTables
-
inferRelationType
public static TableRelationType inferRelationType(String leftTableName, String rightTableName, JOOQMapping preferredKey) - Returns:
- The kind of relation that is present between these tables.
-
hasSelfRelation
- Returns:
- Does this table have any references to itself?
-
recordUsesFSHack
NEW FS hack! Some methods do not use getId(), but getId_() methods for ID... -
tableExists
- Returns:
- Does this table exist in the generated jOOQ code?
-
keyExists
- Returns:
- Does this key exist in the generated jOOQ code?
-
tableOrKeyExists
- Returns:
- Does this table or key exist in the generated jOOQ code?
-
getKeyTargetTable
- Returns:
- Which table does this key point to?
-
getKeySourceTable
- Returns:
- Which table does this key belong to?
-
getKeyFields
public static Optional<Map<org.jooq.TableField<?,?>, getKeyFieldsorg.jooq.TableField<?, ?>>> (JOOQMapping key) -
getRequiredFields
- Returns:
- Set of the names for all the fields that are set as required in the jOOQ table.
-
fieldIsNullable
- Returns:
- Is this field nullable in the jOOQ table?.
-
tableFieldHasDefaultValue
- Returns:
- Does this field have a default value in this jOOQ table? Does not work for views.
-
tableHasIndex
Checks if a table has an index with the specified name.- Parameters:
tableName- The name of the table to check for the index.indexName- The name of the index- Returns:
- Returns true if the table has an index with the same name as provided, false otherwise.
-
getIndex
-
searchTableForMethodWithName
Search this jOOQ table for a method that matches this name.- Parameters:
tableName- Name of the jOOQ table.name- Name that might have a method associated with it.- Returns:
- The name of a method that matches the provided name if it exists.
-
searchTableForKeyMethodName
Search this jOOQ table for a path method that matches the provided key name.- Parameters:
tableName- Name of the jOOQ TablekeyName- Name of the jOOQ ForeignKey- Returns:
- The name of a path method on the table that matches the provided key
-
getTable
-
getForeignKey
-
getJavaFieldNamesForTable
- Returns:
- Set of field names for this table.
-
getJavaFieldNamesForKey
-
getJavaFieldName
-
getClassFromSchemas
-
getTablesByJavaFieldName
-
getForeignKeysByJavaFieldName
-
getField
-
getFieldType
-
fieldTypeIsCLOB
-
getTableClass
-
getRecordClass
-
tableHasPrimaryKey
-
getPrimaryKeyForTable
-
getPrimaryOrUniqueKeyMatchingFields
-
getMethodFromReference
-