Class ColumnProcessor
java.lang.Object
dimstyl.orm.internal.processors.ColumnProcessor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Private constructor to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
determineColumnName
(Column column, String fieldName) Determines the column name based on theColumn
annotation.extractColumnAnnotation
(Field field) Extracts theColumn
annotation from the given field, if present.(package private) static Optional
<ColumnMetadata> extractMetadata
(Field field, DatabaseEngine databaseEngine) Extracts metadata from a given field and constructs aColumnMetadata
object.(package private) static boolean
isPrimaryKey
(Field field) Checks whether the given field is annotated as a primary key.(package private) static String
resolveColumnName
(Field field) Resolves the column name for a given field.
-
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 aColumnMetadata
object.If the field is not annotated with
Column
, an emptyOptional
is returned. Otherwise, column properties such as name, type, primary key status, nullability, and uniqueness are extracted.- Parameters:
field
- The field to process.databaseEngine
- TheDatabaseEngine
for which the column type should be resolved.- Returns:
- An
Optional
containing theColumnMetadata
if the field is annotated, otherwise an emptyOptional
. - Throws:
UnsupportedFieldTypeException
- If the field type is not supported by the ORM framework.
-
isPrimaryKey
Checks whether the given field is annotated as a primary key.- Parameters:
field
- The field to check.- Returns:
true
if the field is annotated withPrimaryKey
, otherwisefalse
.
-
resolveColumnName
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 withColumn
.
-
determineColumnName
Determines the column name based on theColumn
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
- TheColumn
annotation instance.fieldName
- The name of the field.- Returns:
- The resolved column name.
-
extractColumnAnnotation
-