Class NodeIdReferenceHelpers
java.lang.Object
no.sikt.graphitron.generators.context.NodeIdReferenceHelpers
Utility methods for determining whether a @nodeId field is a cross-table reference
and resolving the foreign key and column mappings needed for the generated code.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<org.jooq.ForeignKey<?, ?>> findForeignKeyForNodeIdField(GenerationField field, ProcessedSchema schema, JOOQMapping currentTable) Resolves the foreign key connectingcurrentTableto the node type's target table for a @nodeId reference field.static booleanisNodeIdReferenceField(ObjectField objectField, ProcessedSchema schema) Determines whether a @nodeId field is a reference by resolving the current table from the field's container type or its previous table object.static booleanisNodeIdReferenceField(GenerationField field, ProcessedSchema schema, JOOQMapping currentTable) Determines whether a @nodeId field is a reference.resolveColumnNamesForNodeIdField(GenerationField field, ProcessedSchema schema, JOOQMapping currentTable) Returns the Java column names to use for a @nodeId field given the current table context.
-
Constructor Details
-
NodeIdReferenceHelpers
public NodeIdReferenceHelpers()
-
-
Method Details
-
isNodeIdReferenceField
public static boolean isNodeIdReferenceField(GenerationField field, ProcessedSchema schema, JOOQMapping currentTable) Determines whether a @nodeId field is a reference. Returnstruewhen the field has explicit @reference directives, or when its node type's target table differs fromcurrentTable.- Parameters:
field- the @nodeId fieldschema- the processed schema.currentTable- the current table in which the field is currently being resolved, ornullif unknown.- Returns:
trueif the field references a node on a different table.
-
isNodeIdReferenceField
Determines whether a @nodeId field is a reference by resolving the current table from the field's container type or its previous table object.- Parameters:
objectField- the @nodeId object fieldschema- the processed schema.- Returns:
trueif the field references a node on a different table than its previous table.- See Also:
-
resolveColumnNamesForNodeIdField
public static List<String> resolveColumnNamesForNodeIdField(GenerationField field, ProcessedSchema schema, JOOQMapping currentTable) Returns the Java column names to use for a @nodeId field given the current table context. For references, maps the node's key columns through the foreign key to the current table's columns. Returns the node configuration's key columns directly if the field is not a reference.- Parameters:
field- the field carrying the @nodeId directive.schema- the processed schema.currentTable- the current table in which the field is currently being resolved, ornullif unknown.- Returns:
- ordered list of Java column names for the key fields.
-
findForeignKeyForNodeIdField
public static Optional<org.jooq.ForeignKey<?,?>> findForeignKeyForNodeIdField(GenerationField field, ProcessedSchema schema, JOOQMapping currentTable) Resolves the foreign key connectingcurrentTableto the node type's target table for a @nodeId reference field. Returns empty if the field is not a reference.- Parameters:
field- the @nodeId fieldschema- the processed schema.currentTable- the current table in which the field is currently being resolved, ornullif unknown.- Returns:
- the foreign key, or empty if the field is not a reference.
-