The mappings allow developers to configure how fields or properties should map to database structures, including basic field-column mappings, property-based mappings, and advanced relations such as one-to-many and many-to-many associations.
This builder facilitates a multi-step configuration process where each method represents a specific
stage in defining the field-column specification. The result of the configuration is encapsulated
in a FieldColumnSpec, which can later be used for persistence or ORM-related operations.
The following steps summarise how this builder operates:
- A field or property in a DTO is mapped to begin configuration using
mapFieldormapProperty. - Subsequent methods allow specifying database column names, or defining relationships like one-to-many or many-to-many.
- The resulting configuration is finalised and returned as a complete, immutable spec.
This class supports the creation of specifications using a declarative and type-safe approach. Any ambiguities and potential misconfigurations are resolved at runtime while ensuring a fluent, readable API design.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMaps a specific field in a DTO to begin the configuration process for defining its database column mapping.mapProperty(String fieldName) Maps a specific property in a DTO to begin the configuration process for defining its database property-based mapping.static FieldColumnSpecConstructs aFieldColumnSpecby applying a function to aFieldColumnSpecBuilder.
-
Constructor Details
-
FieldColumnSpecBuilder
public FieldColumnSpecBuilder()
-
-
Method Details
-
mapField
Maps a specific field in a DTO to begin the configuration process for defining its database column mapping. This is the initial step of the field-to-column mapping process using the builder.- Parameters:
fieldName- The name of the field in the DTO to be mapped. This name should correspond to the field in the DTO class and must not benull.- Returns:
- An instance of
FieldColumnSpecBuilderFieldStepto continue the configuration of the field mapping.
-
mapProperty
Maps a specific property in a DTO to begin the configuration process for defining its database property-based mapping. This method assumes property-level access using getter and setter conventions in the DTO class.- Parameters:
fieldName- The name of the property in the DTO to be mapped. This name should correspond to the property in the DTO class and must not benull.- Returns:
- An instance of
FieldColumnSpecBuilderFieldStepto continue the configuration of the property mapping.
-
spec
public static FieldColumnSpec spec(Function<FieldColumnSpecBuilder, FieldColumnSpecBuilderTerminal> rc) Constructs aFieldColumnSpecby applying a function to aFieldColumnSpecBuilder. The function defines the steps and configuration for mapping a field or property in a DTO to its corresponding database column or table specification.- Parameters:
rc- A function that accepts aFieldColumnSpecBuilderand returns aFieldColumnSpecBuilderTerminal. This function defines the sequence of steps required to configure the field-to-column mapping.- Returns:
- A
FieldColumnSpecrepresenting the finalised mapping between the DTO field or property and the database column or table specification.
-