Class ColumnProcessor

java.lang.Object
dimstyl.orm.internal.processors.ColumnProcessor

final class ColumnProcessor extends Object
Utility class responsible for processing column-related metadata in entity classes.

This class extracts metadata from fields annotated with Column and resolves information such as column name, type, primary key status, and constraints.

  • Constructor Details

    • ColumnProcessor

      private ColumnProcessor()
      Private constructor to prevent instantiation.
  • Method Details

    • extractMetadata

      static Optional<ColumnMetadata> extractMetadata(Field field, DatabaseEngine databaseEngine) throws UnsupportedFieldTypeException
      Extracts metadata from a given field and constructs a ColumnMetadata object.

      If the field is not annotated with Column, an empty Optional is returned. Otherwise, column properties such as name, type, primary key status, nullability, and uniqueness are extracted.

      Parameters:
      field - The field to process.
      databaseEngine - The DatabaseEngine for which the column type should be resolved.
      Returns:
      An Optional containing the ColumnMetadata if the field is annotated, otherwise an empty Optional.
      Throws:
      UnsupportedFieldTypeException - If the field type is not supported by the ORM framework.
    • isPrimaryKey

      static boolean isPrimaryKey(Field field)
      Checks whether the given field is annotated as a primary key.
      Parameters:
      field - The field to check.
      Returns:
      true if the field is annotated with PrimaryKey, otherwise false.
    • resolveColumnName

      static String resolveColumnName(Field field) throws MissingColumnAnnotationException
      Resolves the column name for a given field.

      If the field is annotated with Column, its specified name is used. Otherwise, an exception is thrown if the annotation is missing.

      Parameters:
      field - The field whose column name needs to be resolved.
      Returns:
      The resolved column name.
      Throws:
      MissingColumnAnnotationException - If the field is not annotated with Column.
    • determineColumnName

      private static String determineColumnName(Column column, String fieldName)
      Determines the column name based on the Column annotation.

      If the annotation specifies a column name, it is returned. Otherwise, a default name is derived from the field name using StringUtils.getDefaultName(String).

      Parameters:
      column - The Column annotation instance.
      fieldName - The name of the field.
      Returns:
      The resolved column name.
    • extractColumnAnnotation

      private static Optional<Column> extractColumnAnnotation(Field field)
      Extracts the Column annotation from the given field, if present.
      Parameters:
      field - The field to inspect.
      Returns:
      An Optional containing the Column annotation if present, otherwise empty.