### Define Source Model Source: https://modelmapper.org/getting-started Example source classes for mapping demonstrations. ```java // Assume getters and setters on each class class Order { Customer customer; Address billingAddress; } class Customer { Name name; } class Name { String firstName; String lastName; } class Address { String street; String city; } ``` -------------------------------- ### ModelMapper Module Setup Source: https://modelmapper.org/javadoc/index-all.html Provides information on how to set up a ModelMapper module for external functionality. ```APIDOC ## setupModule(ModelMapper) ### Description Setup the ModelMapper for external functionality. ### Method Method ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Module Setup with ModelMapper Source: https://modelmapper.org/javadoc/org/modelmapper/class-use/ModelMapper.html This section details how a module can set up the ModelMapper for external functionality. ```APIDOC ## POST /module/setupModule ### Description Sets up the ModelMapper instance for external functionality within a module. ### Method POST ### Endpoint /module/setupModule ### Parameters #### Request Body - **modelMapper** (ModelMapper) - Required - The ModelMapper instance to set up. ``` -------------------------------- ### Define Simple Source Model Source: https://modelmapper.org/examples/projection Initial source class structure for the first projection example. ```java public class OrderInfo { private String customerName; private String streetAddress; // Assume getters and setters } ``` -------------------------------- ### Define Destination Model Source: https://modelmapper.org/getting-started Example destination DTO class for mapping demonstrations. ```java // Assume getters and setters class OrderDTO { String customerFirstName; String customerLastName; String billingStreet; String billingCity; } ``` -------------------------------- ### Verify Mapping Results Source: https://modelmapper.org/examples/projection Perform the map operation and assert the results for the second example. ```java Order order = modelMapper.map(orderDTO, Order.class); assert order.getAddress().getStreet().equals(orderDTO.getStreet()); assert order.getAddress().getCity().equals(orderDTO.getCity()); ``` -------------------------------- ### Configure destination provider Source: https://modelmapper.org/javadoc/org/modelmapper/builder/ConfigurableProviderExpression.html Examples of using the with method to specify a custom provider for destination property instantiation. ```java with(provider).map(Src::getCustomer, Dest::setCustomer) with(req -> new Customer()).map(Src::getCustomer, Dest::setCustomer) ``` -------------------------------- ### AbstractProvider.get(Provider.ProvisionRequest request) Source: https://modelmapper.org/javadoc/org/modelmapper/class-use/Provider.ProvisionRequest.html This method in AbstractProvider delegates the provisioning of an instance to its own get() method, utilizing a Provider.ProvisionRequest object. ```APIDOC ## AbstractProvider.get(Provider.ProvisionRequest request) ### Description Delegates provisioning to `AbstractProvider.get()`. ### Method `T` (Return Type) ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **T** (Type) - An instance of the requested type `T`. #### Response Example None ``` -------------------------------- ### Get Configuration Source: https://modelmapper.org/javadoc/org/modelmapper/ModelMapper.html Retrieves the current configuration of the ModelMapper. ```APIDOC ## GET /getConfiguration ### Description Returns the ModelMapper's configuration. ### Method GET ### Endpoint /getConfiguration ### Response #### Success Response (200) - **Configuration** (Configuration) - The ModelMapper's configuration object. #### Response Example ```json { "configuration": "{configurationObject}" } ``` ``` -------------------------------- ### Define JSON Order Structure Source: https://modelmapper.org/user-manual/jackson-integration Example JSON input representing an order. ```json { "id": 456, "customer": { "id": 789, "street_address": "123 Main Street", "address_city": "SF" } } ``` -------------------------------- ### GET /modelmapper/configuration Source: https://modelmapper.org/javadoc/org/modelmapper/config/class-use/Configuration.html Retrieves the current configuration instance associated with the ModelMapper. ```APIDOC ## GET /modelmapper/configuration ### Description Returns the ModelMapper's configuration instance. ### Method GET ### Endpoint ModelMapper.getConfiguration() ### Response #### Success Response (200) - **Configuration** (object) - The current configuration object. ``` -------------------------------- ### AbstractConverter Constructor Source: https://modelmapper.org/javadoc/org/modelmapper/AbstractConverter.html Initializes an AbstractConverter. No specific setup is required beyond instantiation. ```java public AbstractConverter() ``` -------------------------------- ### Define Complex Destination Model Source: https://modelmapper.org/examples/projection Target class structure for the first projection example. ```java // Assume getters and setters on each class public class Order { private Customer customer; private Address address; } public class Customer { private String name; } public class Address { private String street; } ``` -------------------------------- ### Define Nested Destination Model Source: https://modelmapper.org/examples/projection Target class structure for the second projection example. ```java // Assume getters and setters on each class public class Order { private Address address; } public class Address { private String street; private String city; } ``` -------------------------------- ### Conditional Mapping with when() Source: https://modelmapper.org/javadoc/org/modelmapper/builder/ConfigurableConditionExpression.html Use the `when` method to conditionally apply a mapping based on a provided condition. This example shows how to map a customer property only when a condition is met. ```java when(condition).map(Src::getCustomer, Dest::setCustomer) ``` ```java with(ctx -> ctx.getSource() != null).map(Src::getCustomer, Dest::setCustomer) ``` -------------------------------- ### Define Flat JSON Structure Source: https://modelmapper.org/user-manual/jackson-integration Example of a differently structured JSON input. ```json { "id": 222, "customer_id": 333, "customer_street_address": "444 Main Street", "customer_address_city": "LA" } ``` -------------------------------- ### Create a Generic Provider Source: https://modelmapper.org/user-manual/providers Implement the Provider interface to create a generic provider that can supply instances of multiple types. The get method receives a ProvisionRequest containing the requested type, allowing for dynamic instantiation. ```java Provider delegatingProvider = new Provider() { public Object get(ProvisionRequest request) { return SomeFactory.getInstance(request.getRequestedType()); } } ``` -------------------------------- ### Define DTO Source Model Source: https://modelmapper.org/examples/projection Source class structure for the second projection example. ```java public class OrderDTO { private String street; private String city; // Assume getters and setters } ``` -------------------------------- ### Define complex source model Source: https://modelmapper.org/examples/flattening Example classes representing a nested object structure. ```java // Assume getters and setters on each class public class Order { Customer customer; Address shippingAddress; Address billingAddress; } public class Customer { String name; } public class Address { String street; String city; } ``` -------------------------------- ### void setupModule(ModelMapper modelMapper) Source: https://modelmapper.org/javadoc/org/modelmapper/Module.html Registers an extension with the ModelMapper instance. ```APIDOC ## setupModule ### Description Setup the ModelMapper for external functionality. ### Parameters #### Parameters - **modelMapper** (ModelMapper) - Required - A ModelMapper instance to be configured. ``` -------------------------------- ### Tokens - Size Source: https://modelmapper.org/javadoc/index-all.html Method to get the size of Tokens. ```APIDOC ## size() ### Description Returns the size of the Tokens. ### Method Method ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### GET /typeMaps Source: https://modelmapper.org/javadoc/org/modelmapper/ModelMapper.html Retrieves all TypeMaps associated with the ModelMapper. ```APIDOC ## GET /typeMaps ### Description Returns a collection of all TypeMaps currently defined for the ModelMapper. ### Response #### Success Response (200) - **Collection>** - A collection of all TypeMaps ``` -------------------------------- ### Configuration API for NamingConvention Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/NamingConvention.html APIs for setting and getting NamingConvention in the configuration. ```APIDOC ## GET Configuration.getDestinationNamingConvention() ### Description Returns the destination naming convention. ### Method GET ### Endpoint /configuration/destinationNamingConvention ### Response #### Success Response (200) - **NamingConvention** (NamingConvention) - The destination naming convention. #### Response Example ```json { "namingConvention": "JAVABEANS_ACCESSOR" } ``` ## GET Configuration.getSourceNamingConvention() ### Description Gets the source naming convention. ### Method GET ### Endpoint /configuration/sourceNamingConvention ### Response #### Success Response (200) - **NamingConvention** (NamingConvention) - The source naming convention. #### Response Example ```json { "namingConvention": "JAVABEANS_ACCESSOR" } ``` ## POST Configuration.setDestinationNamingConvention(NamingConvention namingConvention) ### Description Sets the convention used to identify destination property names during the matching process. ### Method POST ### Endpoint /configuration/destinationNamingConvention ### Parameters #### Request Body - **namingConvention** (NamingConvention) - Required - The naming convention to set for destination properties. ### Request Example ```json { "namingConvention": "JAVABEANS_ACCESSOR" } ``` ### Response #### Success Response (200) - **message** (string) - Indicates successful update. #### Response Example ```json { "message": "Destination naming convention set successfully." } ``` ## POST Configuration.setSourceNamingConvention(NamingConvention namingConvention) ### Description Sets the convention used to identify source property names during the matching process. ### Method POST ### Endpoint /configuration/sourceNamingConvention ### Parameters #### Request Body - **namingConvention** (NamingConvention) - Required - The naming convention to set for source properties. ### Request Example ```json { "namingConvention": "JAVABEANS_ACCESSOR" } ``` ### Response #### Success Response (200) - **message** (string) - Indicates successful update. #### Response Example ```json { "message": "Source naming convention set successfully." } ``` ``` -------------------------------- ### GET /condition Source: https://modelmapper.org/javadoc/org/modelmapper/class-use/Condition.html Retrieves the condition that must be satisfied before a mapping can be performed. ```APIDOC ## GET /condition ### Description Gets the condition that must be satisfied before this mapping can be used to perform a mapping. ### Method GET ### Endpoint /condition ### Response #### Success Response (200) - **condition** (Object) - The condition object that must be satisfied for the mapping to proceed. ``` -------------------------------- ### Method: with(Provider provider) Source: https://modelmapper.org/javadoc/org/modelmapper/builder/ConfigurableProviderExpression.html Configures a provider to be used for instantiating an instance for a destination property. ```APIDOC ## with(Provider provider) ### Description Uses the provided provider to instantiate an instance for a destination property. ### Parameters - **provider** (Provider) - Required - A provider to instantiate the destination property. ### Request Example ```java with(provider).map(Src::getCustomer, Dest::setCustomer); with(req -> new Customer()).map(Src::getCustomer, Dest::setCustomer); ``` ### Response - **Returns** (ConfigurableConverterExpression) - The expression for further configuration. ``` -------------------------------- ### ConfigurableProviderExpression.with() Method Source: https://modelmapper.org/javadoc/org/modelmapper/builder/class-use/ConfigurableConverterExpression.html Explains how to use a provider to instantiate a destination property using ConfigurableConverterExpression. ```APIDOC ## Method ConfigurableProviderExpression.with(Provider provider) ### Description Uses `provider` to instantiate an instance for destination property. ### Returns `ConfigurableConverterExpression` ``` -------------------------------- ### GET /typeMap Source: https://modelmapper.org/javadoc/org/modelmapper/ModelMapper.html Retrieves or creates a TypeMap for specified source and destination types. ```APIDOC ## GET /typeMap ### Description Returns the TypeMap for the sourceType, destinationType, and typeMapName. Creates a TypeMap automatically if none exists. ### Parameters #### Path Parameters - **sourceType** (Class) - Required - The source type class - **destinationType** (Class) - Required - The destination type class - **typeMapName** (String) - Required - The name of the TypeMap ### Response #### Success Response (200) - **TypeMap** - The requested TypeMap instance ``` -------------------------------- ### Get All TypeMaps Source: https://modelmapper.org/javadoc/org/modelmapper/ModelMapper.html Retrieves a collection of all TypeMaps currently managed by the ModelMapper instance. ```java public Collection> getTypeMaps() ``` -------------------------------- ### AbstractProvider Class Source: https://modelmapper.org/javadoc/org/modelmapper/AbstractProvider.html Documentation for the AbstractProvider class and its methods for object provisioning. ```APIDOC ## Class: org.modelmapper.AbstractProvider ### Description Support class for the Provider interface. Allows for simpler Provider implementations by delegating the provisioning request. ### Methods #### get(Provider.ProvisionRequest request) - **Description**: Delegates provisioning to the abstract get() method. - **Parameters**: - **request** (Provider.ProvisionRequest) - Required - Information regarding the provision request. #### get() - **Description**: Provides an instance of type T. This method must be implemented by subclasses. - **Returns**: T - An instance of the requested type. #### toString() - **Description**: Returns a string representation of the object. ``` -------------------------------- ### Naming and Convention Configuration Source: https://modelmapper.org/javadoc/org/modelmapper/config/Configuration.html Configure how property and class names are transformed and which conventions are used for identifying destination property names. ```APIDOC ## POST /websites/modelmapper/configuration/nameTransformer ### Description Sets the name transformer used to transform destination property and class names during the matching process. ### Method POST ### Endpoint /websites/modelmapper/configuration/nameTransformer ### Parameters #### Request Body - **nameTransformer** (Object) - Required - The transformer to use for naming. ### Response #### Success Response (200) - **Configuration** (Object) - The updated configuration object. ### Response Example ```json { "configuration": "updated_configuration_object" } ``` ## POST /websites/modelmapper/configuration/destinationNamingConvention ### Description Sets the convention used to identify destination property names during the matching process. ### Method POST ### Endpoint /websites/modelmapper/configuration/destinationNamingConvention ### Parameters #### Request Body - **namingConvention** (Object) - Required - The naming convention to use. ### Response #### Success Response (200) - **Configuration** (Object) - The updated configuration object. ### Response Example ```json { "configuration": "updated_configuration_object" } ``` ``` -------------------------------- ### Configuration Methods Source: https://modelmapper.org/javadoc/org/modelmapper/config/class-use/Configuration.html Methods for setting naming conventions and OSGi class loader bridging in the ModelMapper Configuration object. ```APIDOC ## POST /configuration/naming-convention ### Description Sets the convention used to identify source property names during the matching process. ### Method POST ### Parameters #### Request Body - **namingConvention** (NamingConvention) - Required - The convention used to identify source property names. --- ## POST /configuration/osgi-bridging ### Description Sets whether to use an OSGi Class Loader Bridge. ### Method POST ### Parameters #### Request Body - **useOSGiClassLoaderBridging** (boolean) - Required - Flag to enable or disable OSGi Class Loader Bridge. ``` -------------------------------- ### Mapping EDSL - Basic Mapping Source: https://modelmapper.org/javadoc/org/modelmapper/PropertyMap.html Demonstrates how to use the Mapping EDSL to map properties, methods, and constant values between source and destination objects. ```APIDOC ## Mapping EDSL - Basic Mapping ### Description PropertyMap uses an Embedded Domain Specific Language (EDSL) to define how source and destination methods and values map to each other. The Mapping EDSL allows you to define mappings using actual code that references the source and destination properties you wish to map. ### Mapping Methods - Map destination `setName` to source `getFirstName`: ```java map().setName(source.getFirstName()); ``` - Map destination `setLastName` to source `surName` field: ```java map().setLastName(source.surName); ``` - Map source `surName` field directly to destination `lastName` field: ```java map(source.surName, destination.lastName); ``` - Map destination `setEmployer` to a constant value: ```java map().setEmployer("Initech"); ``` - Map a constant value to destination `employer` field: ```java map("Initech", destination.employer); ``` - Map methods with non-matching types: ```java map(source.getAge()).setAgeString(null); ``` - Map constant values with non-matching types: ```java map(21).setAgeString(null); ``` **Note**: When a value is provided on the left-hand side of a `map` method, any value provided on the right-hand side in a setter is not used. ``` -------------------------------- ### GET ValueReader.Member Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/ValueReader.Member.html Retrieves a ValueReader.Member from a source object based on the provided member name. ```APIDOC ## GET ValueReader.getMember ### Description Returns the ValueReader.Member from the source within the given memberName. ### Method GET ### Parameters #### Path Parameters - **source** (T) - Required - The source object to read from. - **memberName** (String) - Required - The name of the member to retrieve. ### Response #### Success Response (200) - **ValueReader.Member** - The member object associated with the specified name. ``` -------------------------------- ### Method: accept Source: https://modelmapper.org/javadoc/org/modelmapper/spi/DestinationSetter.html Performs an operation to set a value into a destination object. ```APIDOC ## void accept(D destination, V value) ### Description Performs this operation to set the value into destination. ### Parameters - **destination** (D) - Required - The instance of destination. - **value** (V) - Required - The value from source. ``` -------------------------------- ### Configure Pre and Post Converters Source: https://modelmapper.org/user-manual/converters Use pre and post converters to execute logic in addition to existing mappings. ```java personTypeMap.setPreConverter(personConverter); ``` ```java personTypeMap.setPostConverter(personConverter); ``` -------------------------------- ### TypeSafeSourceGetter Interface Source: https://modelmapper.org/javadoc/org/modelmapper/spi/TypeSafeSourceGetter.html Details of the TypeSafeSourceGetter interface, including its type parameters and the 'get' method. ```APIDOC ## Interface TypeSafeSourceGetter ### Description Represents an operation for getting a property from a source. ### Type Parameters * `S` - source type * `P` - property type ### Methods #### get `P get(S source)` Performs this operation to get a property from source. ##### Parameters * `source` (S) - The source instance. ##### Returns * `P` - The property from source. ``` -------------------------------- ### Define flattened destination model Source: https://modelmapper.org/examples/flattening Example DTO class representing the flattened structure. ```java public class OrderDTO { String customerName; String shippingStreetAddress; String shippingCity; String billingStreetAddress; String billingCity; // Assume getters and setters } ``` -------------------------------- ### TypeToken Methods Source: https://modelmapper.org/javadoc/org/modelmapper/TypeToken.html Provides details on the methods available in the TypeToken class, including static and instance methods. ```APIDOC ## Method Summary ### static TypeToken of(Type type) Returns a TypeLiteral for the `type`. **Parameters:** * **type** (Type) - The type for which to create a TypeToken. **Throws:** * `IllegalArgumentException` - if `type` is null or if a raw type cannot be resolved ### final boolean equals(Object o) Overrides the `equals` method from the `Object` class. ### final Class getRawType() Returns the raw type for `T`. * If `T` is a `Class`, `T` itself is returned. * If `T` is a `ParameterizedType`, the raw type is returned. * If `T` is a `GenericArrayType`, the raw type is returned. * If `T` is a `TypeVariable` or `WildcardType`, the raw type of the first upper bound is returned. ### final Type getType() Returns the generic type `T`. ### final int hashCode() Overrides the `hashCode` method from the `Object` class. ### final String toString() Overrides the `toString` method from the `Object` class. ``` -------------------------------- ### Configure Provider for Property Mapping Source: https://modelmapper.org/user-manual/property-mapping Configure a provider to supply instances for a specific property mapping using the 'with' method. This ensures the correct type of object is available for mapping. ```java with(personProvider).map().setPerson(source.getPerson()); ``` ```java typeMap.addMappings(mapper -> mapper.with(personProvider).map(Source::getPerson, Destination::setPerson)); ``` ```java typeMap.addMappings(mapper -> mapper.with(req -> new Person()).map(Source::getPerson, Destination::setPerson)); ``` -------------------------------- ### MappingException Constructors and Methods Source: https://modelmapper.org/javadoc/org/modelmapper/MappingException.html Details on how to create and use the MappingException, including its constructors and methods for retrieving error information. ```APIDOC ## MappingException Indicates that an error has occurred during a mapping operation. ### Constructor Summary Constructors Constructor Description `MappingException(List messages)` ### Method Summary All Methods Instance Methods Concrete Methods Modifier and Type Method Description `Collection` `getErrorMessages()` Returns messages for the errors that caused this exception. `String` `getMessage()` ### Constructor Details * ### MappingException `public MappingException(List messages)` ### Method Details * ### getMessage `public String getMessage()` Overrides: `getMessage` in class `Throwable` * ### getErrorMessages `public Collection getErrorMessages()` Returns messages for the errors that caused this exception. ``` -------------------------------- ### Perform Basic Mapping Source: https://modelmapper.org/examples/projection Execute the mapping operation from OrderInfo to Order. ```java ModelMapper modelMapper = new ModelMapper(); Order order = modelMapper.map(orderInfo, Order.class); ``` -------------------------------- ### Conditions and Naming Conventions Source: https://modelmapper.org/javadoc/index-all.html Information on using conditions for mapping logic and configuring naming conventions. ```APIDOC ## POST /api/modelmapper/conditions ### Description Combines conditions for conditional mapping. ### Method POST ### Endpoint /api/modelmapper/conditions ### Request Body - **condition1** (Condition) - Required - The first condition. - **condition2** (Condition) - Required - The second condition. ### Request Example ```json { "condition1": "com.example.ConditionA", "condition2": "com.example.ConditionB" } ``` ### Response #### Success Response (200) - **combinedCondition** (Condition) - The resulting combined condition. #### Response Example ```json { "combinedCondition": "com.example.CombinedCondition" } ``` ```APIDOC ## POST /api/modelmapper/naming-conventions/builder ### Description Creates a NamingConvention for builder-style property names. ### Method POST ### Endpoint /api/modelmapper/naming-conventions/builder ### Request Body - **prefix** (string) - Optional - A prefix for builder methods. ### Request Example ```json { "prefix": "with" } ``` ### Response #### Success Response (200) - **namingConvention** (NamingConvention) - The configured NamingConvention. #### Response Example ```json { "namingConvention": "org.modelmapper.convention.BuilderNamingConvention" } ``` -------------------------------- ### Execute and verify mapping Source: https://modelmapper.org/examples/flattening Performing the map operation after configuration and verifying the results. ```java PersonDTO dto = modelMapper.map(person, PersonDTO.class); assert dto.getStreet().equals(person.getAddress().getStreet()); assert dto.getCity().equals(person.getAddress().getCity()); ``` -------------------------------- ### Use Guice Provider for Individual Mappings Source: https://modelmapper.org/user-manual/guice-integration Apply a Guice-integrated Provider to an individual mapping operation. This allows for fine-grained control over object provisioning for specific mappings. ```java with(guiceProvider).map().someSetter(source.someGetter()); ``` -------------------------------- ### Value Reader/Writer Member Types Source: https://modelmapper.org/javadoc/index-all.html Methods to get the value type for ValueReader and ValueWriter members. ```APIDOC ## GET /valueReader/member/valueType ### Description Gets the value type for the ValueReader member. ### Method GET ### Endpoint /valueReader/member/valueType ## GET /valueWriter/member/valueType ### Description Gets the value type for the ValueWriter member. ### Method GET ### Endpoint /valueWriter/member/valueType ``` -------------------------------- ### GET /org.modelmapper.spi/ValueWriter/getMember Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/ValueWriter.Member.html Retrieves a ValueWriter.Member from the destination based on the provided destination type and member name. ```APIDOC ## GET /org.modelmapper.spi/ValueWriter/getMember ### Description Returns the ValueWriter.Member from the destination within a given memberName. ### Method GET ### Endpoint /org.modelmapper.spi/ValueWriter/getMember ### Parameters #### Query Parameters - **destinationType** (Class) - Required - The class type of the destination. - **memberName** (String) - Required - The name of the member to retrieve. ### Response #### Success Response (200) - **ValueWriter.Member** (Object) - The requested member instance. ``` -------------------------------- ### Provide Custom Person Instances Source: https://modelmapper.org/user-manual/property-mapping Use an AbstractProvider to define custom logic for creating destination objects like Person. This is useful when default instantiation is insufficient. ```java Provider personProvider = new AbstractProvider() { public Person get() { return new Person(); } } ``` ```java Provider personProvider = req -> new Person(); ``` -------------------------------- ### Configuration API for NameTransformer Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/NameTransformer.html APIs for setting and getting NameTransformer instances within the ModelMapper configuration. ```APIDOC ## GET Configuration.getDestinationNameTransformer() ### Description Returns the destination name transformer. ### Method GET ### Endpoint N/A (Method within Configuration class) ### Response #### Success Response (200) - **NameTransformer** (NameTransformer) - The configured destination name transformer. ### Response Example ```json { "example": "NameTransformer instance" } ``` ## GET Configuration.getSourceNameTransformer() ### Description Returns the source name transformer. ### Method GET ### Endpoint N/A (Method within Configuration class) ### Response #### Success Response (200) - **NameTransformer** (NameTransformer) - The configured source name transformer. ### Response Example ```json { "example": "NameTransformer instance" } ``` ## POST Configuration.setDestinationNameTransformer(NameTransformer nameTransformer) ### Description Sets the name transformer used to transform destination property and class names during the matching process. ### Method POST ### Endpoint N/A (Method within Configuration class) ### Parameters #### Request Body - **nameTransformer** (NameTransformer) - Required - The name transformer to set for destination names. ### Request Example ```json { "example": "NameTransformer instance" } ``` ## POST Configuration.setSourceNameTransformer(NameTransformer nameTransformer) ### Description Sets the name transformer used to transform source property and class names during the matching process. ### Method POST ### Endpoint N/A (Method within Configuration class) ### Parameters #### Request Body - **nameTransformer** (NameTransformer) - Required - The name transformer to set for source names. ### Request Example ```json { "example": "NameTransformer instance" } ``` ``` -------------------------------- ### Configuration Methods Source: https://modelmapper.org/javadoc/org/modelmapper/config/Configuration.html Methods for configuring the mapping behavior of ModelMapper instances. ```APIDOC ## setMatchingStrategy ### Description Sets the strategy used to match source properties to destination properties. ### Parameters #### Request Body - **matchingStrategy** (MatchingStrategy) - Required - The strategy to use for matching. ### Errors - **IllegalArgumentException** - if matchingStrategy is null ## setMethodAccessLevel ### Description Indicates that methods should be eligible for matching at the given accessLevel. ### Parameters #### Request Body - **accessLevel** (Configuration.AccessLevel) - Required - The access level for method matching. ### Errors - **IllegalArgumentException** - if accessLevel is null ## setPropertyCondition ### Description Sets the condition that must apply for a property in order for mapping to take place. ### Parameters #### Request Body - **condition** (Condition) - Required - The condition to apply. ### Errors - **IllegalArgumentException** - if condition is null ## setProvider ### Description Sets the provider to use for providing destination object instances. ### Parameters #### Request Body - **provider** (Provider) - Required - The provider to register. ### Errors - **IllegalArgumentException** - if provider is null ## setSourceNameTokenizer ### Description Sets the tokenizer to be applied to source property and class names during the matching process. ### Parameters #### Request Body - **nameTokenizer** (NameTokenizer) - Required - The tokenizer to apply. ### Errors - **IllegalArgumentException** - if nameTokenizer is null ## setSourceNameTransformer ### Description Sets the name transformer used to transform source property and class names during the matching process. ### Parameters #### Request Body - **nameTransformer** (NameTransformer) - Required - The transformer to apply. ### Errors - **IllegalArgumentException** - if nameTransformer is null ## setSourceNamingConvention ### Description Sets the convention used to identify source property names during the matching process. ### Parameters #### Request Body - **namingConvention** (NamingConvention) - Required - The naming convention to apply. ### Errors - **IllegalArgumentException** - if namingConvention is null ``` -------------------------------- ### Configuration API for NameTokenizer Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/NameTokenizer.html APIs for getting and setting the NameTokenizer used in ModelMapper's configuration. ```APIDOC ## GET Configuration.getDestinationNameTokenizer() ### Description Returns the destination name tokenizer. ### Method GET ### Endpoint N/A (Method within Configuration class) ### Response #### Success Response (200) - **NameTokenizer** (NameTokenizer) - The configured destination name tokenizer. ## GET Configuration.getSourceNameTokenizer() ### Description Returns the source name tokenizer. ### Method GET ### Endpoint N/A (Method within Configuration class) ### Response #### Success Response (200) - **NameTokenizer** (NameTokenizer) - The configured source name tokenizer. ## POST Configuration.setDestinationNameTokenizer(NameTokenizer nameTokenizer) ### Description Sets the tokenizer to be applied to destination property and class names during the matching process. ### Method POST ### Endpoint N/A (Method within Configuration class) ### Parameters #### Request Body - **nameTokenizer** (NameTokenizer) - Required - The tokenizer to set for destination names. ## POST Configuration.setSourceNameTokenizer(NameTokenizer nameTokenizer) ### Description Sets the tokenizer to be applied to source property and class names during the matching process. ### Method POST ### Endpoint N/A (Method within Configuration class) ### Parameters #### Request Body - **nameTokenizer** (NameTokenizer) - Required - The tokenizer to set for source names. ``` -------------------------------- ### Define source model for loose matching Source: https://modelmapper.org/examples/flattening Source classes for demonstrating property matching challenges. ```java // Assume getters and setters on each class public class Person { Address address; } public class Address { String street; String city; } ``` -------------------------------- ### Tokens Factory Method Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/Tokens.html Static factory method for creating Tokens instances. ```APIDOC ## POST Tokens.of(String... tokens) ### Description Creates a new Tokens instance from the provided string tokens. ### Parameters #### Request Body - **tokens** (String...) - Required - Variable number of string tokens to include. ``` -------------------------------- ### Configuration API Source: https://modelmapper.org/javadoc/org/modelmapper/config/package-summary.html Details about the Configuration class and its related types for setting up ModelMapper. ```APIDOC ## Configuration Class ### Description Configures conventions used during the matching process. ### Related Packages - **org.modelmapper**: ModelMapper is an intelligent object mapping library. - **org.modelmapper.builder**: Expression types for building Mappings and TypeMaps. - **org.modelmapper.convention**: Conventions. - **org.modelmapper.spi**: Service Provider Interface. ### Related Classes and Interfaces - **Configuration.AccessLevel**: The level at and below which properties can be accessed. ``` -------------------------------- ### SourceGetter Interface Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/TypeSafeSourceGetter.html Details the SourceGetter interface within the ModelMapper SPI, which represents an operation for getting a property from a source. ```APIDOC ## SourceGetter ### Description Represents an operation for getting a property from a source object. ### Method Interface Definition ### Endpoint None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get TypeMap Overloads Source: https://modelmapper.org/javadoc/org/modelmapper/ModelMapper.html Provides methods to retrieve existing TypeMaps based on source and destination types, with an optional name. ```APIDOC ## GET /getTypeMap ### Description Returns the TypeMap for the `sourceType` and `destinationType`, else returns `null` if none exists. ### Method GET ### Endpoint /getTypeMap ### Parameters #### Query Parameters - **sourceType** (Class) - Required - The source class. - **destinationType** (Class) - Required - The destination class. ### Response #### Success Response (200) - **TypeMap** (TypeMap) - The TypeMap if found, otherwise null. #### Response Example ```json { "typeMap": "{typeMapObject}" } ``` ### Throws - `IllegalArgumentException` - is `sourceType` or `destinationType` are null. ``` ```APIDOC ## GET /getTypeMap ### Description Returns the TypeMap for the `sourceType`, `destinationType` and `typeMapName`, else returns `null` if none exists. ### Method GET ### Endpoint /getTypeMap ### Parameters #### Query Parameters - **sourceType** (Class) - Required - The source class. - **destinationType** (Class) - Required - The destination class. - **typeMapName** (String) - Required - The name of the TypeMap. ### Response #### Success Response (200) - **TypeMap** (TypeMap) - The TypeMap if found, otherwise null. #### Response Example ```json { "typeMap": "{typeMapObject}" } ``` ### Throws - `IllegalArgumentException` - is `sourceType`, `destinationType` or `typeMapName` are null. ``` -------------------------------- ### TypeToken Constructors Source: https://modelmapper.org/javadoc/org/modelmapper/TypeToken.html Details the available constructors for the TypeToken class. ```APIDOC ## Constructor Summary ### protected TypeToken() Creates a new type token for `T`. **Throws:** * `IllegalArgumentException` - if `T` is not provided or is a TypeVariable ``` -------------------------------- ### Obtain Dagger Integrated Provider Source: https://modelmapper.org/user-manual/dagger-integration Get a Dagger integrated Provider that delegates to an ObjectGraph. This is the first step in configuring ModelMapper for Dagger. ```java Provider daggerProvider = DaggerIntegration.fromDagger(objectGraph); ``` -------------------------------- ### TypeMap Configuration Methods Source: https://modelmapper.org/javadoc/org/modelmapper/TypeMap.html Methods for configuring property providers and converters for a TypeMap. ```APIDOC ## setPropertyProvider ### Description Sets the provider to be used for providing instances of properties during mapping. This is overridden by any providers defined in a PropertyMap. ### Parameters - **provider** (Provider) - Required - The property provider instance. ### Throws - IllegalArgumentException if provider is null ## setProvider ### Description Sets the provider to be used for providing instances of destination type D during mapping. ### Parameters - **provider** (Provider) - Required - The destination type provider instance. ### Throws - IllegalArgumentException if provider is null ``` -------------------------------- ### TypeMap Configuration and Mapping Source: https://modelmapper.org/javadoc/org/modelmapper/TypeMap.html This section covers the core methods of the TypeMap class for configuring mapping behavior and executing mappings. ```APIDOC ## TypeMap API ### `map(S source)` Maps `source` to an instance of type `D`. #### Parameters - **source** (S) - Required - object to map from #### Returns - **D** - fully mapped instance of type `D` #### Throws - `IllegalArgumentException` - if `source` is null - `MappingException` - if an error occurs while mapping ### `map(S source, D destination)` Maps `source` to `destination`. #### Parameters - **source** (S) - Required - object to map from - **destination** (D) - Required - object to map to #### Throws - `IllegalArgumentException` - if `source` or `destination` are null - `MappingException` - if an error occurs while mapping ### `setCondition(Condition condition)` Sets the `condition` that must apply for the source and destination in order for mapping to take place. #### Parameters - **condition** (Condition) - Required - The condition to set #### Returns - **TypeMap** - This TypeMap instance #### Throws - `IllegalArgumentException` - if `condition` is null ### `setConverter(Converter converter)` Sets the `converter` to be used for any conversion requests for the TypeMap's source to destination type. This converter will be used in place of any mappings that have been added to the TypeMap. #### Parameters - **converter** (Converter) - Required - The converter to set #### Returns - **TypeMap** - This TypeMap instance #### Throws - `IllegalArgumentException` - if `converter` is null ### `setPostConverter(Converter converter)` Sets the `converter` to be used after mapping between the source and destination types. #### Parameters - **converter** (Converter) - Required - The converter to set #### Returns - **TypeMap** - This TypeMap instance #### Throws - `IllegalArgumentException` - if `converter` is null ### `setPreConverter(Converter converter)` Sets the `converter` to be used before mapping between the source and destination types. #### Parameters - **converter** (Converter) - Required - The converter to set #### Returns - **TypeMap** - This TypeMap instance #### Throws - `IllegalArgumentException` - if `converter` is null ### `setPropertyCondition(Condition condition)` Sets the `condition` that must apply in order for properties in this TypeMap to be mapped. This is overridden by any conditions defined in a PropertyMap. #### Parameters - **condition** (Condition) - Required - The condition to set #### Returns - **TypeMap** - This TypeMap instance #### Throws - `IllegalArgumentException` - if `condition` is null ### `setPropertyConverter(Converter converter)` Sets the `converter` used for converting properties in the TypeMap. #### Parameters - **converter** (Converter) - Required - The converter to set #### Returns - **TypeMap** - This TypeMap instance #### Throws - `IllegalArgumentException` - if `converter` is null ``` -------------------------------- ### Provider Interface Usage in ModelMapper Configuration Source: https://modelmapper.org/javadoc/org/modelmapper/class-use/Provider.html This section outlines the usage of the Provider interface within the `org.modelmapper.config` package, including methods for getting and setting providers. ```APIDOC ## Provider Interface Usage in org.modelmapper.config ### Description This section details methods within the `org.modelmapper.config` package that interact with the `Provider` interface. ### Methods Returning Provider #### `Configuration.getProvider()` - **Returns**: `Provider` - The Provider used for provisioning destination object instances, or `null` if none is configured. ### Methods Accepting Provider #### `Configuration.setProvider(Provider provider)` - **Parameters**: - **provider** (`Provider`) - Required - Sets the `provider` to use for providing destination object instances. ``` -------------------------------- ### Get TypeMap for Source and Destination Types Source: https://modelmapper.org/javadoc/org/modelmapper/ModelMapper.html Retrieves an existing TypeMap or creates one automatically if it doesn't exist. Ensure source, destination types, and type map name are not null. ```java public TypeMap typeMap(Class sourceType, Class destinationType, String typeMapName) ``` -------------------------------- ### Configuration API Source: https://modelmapper.org/javadoc/index-all.html Methods for retrieving global ModelMapper configuration settings. ```APIDOC ## GET /Configuration ### Description Retrieves global configuration settings for the ModelMapper instance. ### Methods - **getMatchingStrategy()**: Gets the matching strategy. - **getMethodAccessLevel()**: Returns the method access level. - **getPropertyCondition()**: Returns the global property condition. - **getProvider()**: Returns the global Provider. ``` -------------------------------- ### Configuration Interface Methods Source: https://modelmapper.org/javadoc/index-all.html Methods for configuring global mapping behavior in ModelMapper. ```APIDOC ## Configuration Methods ### setAmbiguityIgnored(boolean) Sets whether destination properties that match more than one source property should be ignored. ### setCollectionsMergeEnabled(boolean) Sets whether the 'merging' of collections should be enabled. ### setDeepCopyEnabled(boolean) Sets whether deep copy should be enabled. ### setFieldAccessLevel(Configuration.AccessLevel) Indicates that fields should be eligible for matching at the given accessLevel. ### setFieldMatchingEnabled(boolean) Sets whether field matching should be enabled. ### setImplicitMappingEnabled(boolean) Sets whether implicit mapping should be enabled. ### setMatchingStrategy(MatchingStrategy) Sets the strategy used to match source properties to destination properties. ### setSkipNullEnabled(boolean) Sets whether a property should be skipped or not when the property value is null. ``` -------------------------------- ### Configuration and Providers Source: https://modelmapper.org/javadoc/index-all.html Details on configuring ModelMapper, including value readers and writers, and provider support. ```APIDOC ## POST /api/modelmapper/configuration/value-readers ### Description Registers a ValueReader to be used when mapping from instances of a specific type. ### Method POST ### Endpoint /api/modelmapper/configuration/value-readers ### Request Body - **valueReader** (ValueReader) - Required - The ValueReader instance to register. ### Request Example ```json { "valueReader": "com.example.MyValueReader" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the ValueReader was registered. #### Response Example ```json { "message": "ValueReader registered successfully." } ``` ```APIDOC ## POST /api/modelmapper/configuration/value-writers ### Description Registers a ValueWriter to be used when mapping properties to instances of a specific type. ### Method POST ### Endpoint /api/modelmapper/configuration/value-writers ### Request Body - **valueWriter** (ValueWriter) - Required - The ValueWriter instance to register. ### Request Example ```json { "valueWriter": "com.example.MyValueWriter" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the ValueWriter was registered. #### Response Example ```json { "message": "ValueWriter registered successfully." } ``` -------------------------------- ### ValueReader.Member Class Source: https://modelmapper.org/javadoc/org/modelmapper/spi/ValueReader.Member.html Documentation for the ValueReader.Member class, its constructors, and methods. ```APIDOC ## Class ValueReader.Member ### Description A member of a given source. ### Type Parameters - `T` - source type ### Enclosing interface - `ValueReader` ### Constructor Summary #### Constructors - `Member(Class valueType)`: Creates a member contains nested value. ### Method Summary #### Instance Methods - `Object get(T source, String memberName)`: Get the member from the source with given member name. - `T getOrigin()`: The origin value of this member. - `Class getValueType()`: Gets the type of the value. ### Constructor Details #### Member ```java public Member(Class valueType) ``` Creates a member contains nested value. **Parameters:** - `valueType` (Class) - the value type ### Method Details #### getValueType ```java public Class getValueType() ``` #### getOrigin ```java public T getOrigin() ``` The origin value of this member. **Returns:** - the origin value (T) #### get ```java public abstract Object get(T source, String memberName) ``` Get the member from the source with given member name. **Parameters:** - `source` (T) - the source - `memberName` (String) - the member name **Returns:** - the member of the source (Object) ``` -------------------------------- ### Using custom converters in ModelMapper Source: https://modelmapper.org/javadoc/org/modelmapper/builder/ConfigurableConverterExpression.html Demonstrates how to apply a custom converter to a property mapping using the using method. ```java using(converter).map(Src::getCustomer, Dest::setCustomerId) using(ctx -> ctx.getSource().getName().toUpperCase()).map(src -> src.getCustomer().getId(), Dest::setCustomerId) ``` -------------------------------- ### Use Provider for Individual Mappings Source: https://modelmapper.org/user-manual/dagger-integration Utilize the Dagger integrated Provider for individual mappings. This provides granular control over object provisioning. ```java with(daggerProvider).map().someSetter(source.someGetter()); ``` -------------------------------- ### PropertyMap Basics Source: https://modelmapper.org/javadoc/org/modelmapper/PropertyMap.html Defines custom mappings between source and destination types by extending PropertyMap and overriding the configure() method. ```APIDOC ## PropertyMap ### Description A PropertyMap defines mappings between properties for a particular source and destination type. To create a PropertyMap simply extend `PropertyMap`, supplying type arguments to represent the source type `` and destination type ``, then override the `configure()` method. ### Example ```java public class OrderMap extends PropertyMap() { protected void configure() { map().setCustomer(source.getCustomerName()); map().address.setStreet(source.address.streetName); } }; ``` ``` -------------------------------- ### Configure Loose Matching Strategy Source: https://modelmapper.org/examples/projection Set the matching strategy to allow mapping when hierarchy tokens are missing. ```java modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.LOOSE); ``` -------------------------------- ### Configuration API for MatchingStrategy Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/MatchingStrategy.html APIs related to configuring the MatchingStrategy within ModelMapper's Configuration. ```APIDOC ## GET Configuration.getMatchingStrategy() ### Description Gets the matching strategy. ### Method GET ### Endpoint Configuration.getMatchingStrategy() ## POST Configuration.setMatchingStrategy(MatchingStrategy matchingStrategy) ### Description Sets the strategy used to match source properties to destination properties. ### Method POST ### Endpoint Configuration.setMatchingStrategy(MatchingStrategy matchingStrategy) ### Parameters #### Path Parameters - **matchingStrategy** (MatchingStrategy) - Required - The strategy to set for matching properties. ``` -------------------------------- ### Configuration API for ValueReaders Source: https://modelmapper.org/javadoc/org/modelmapper/spi/class-use/ValueReader.html This section covers the methods available in the Configuration class for managing ValueReaders. ```APIDOC ## GET Configuration.getValueReaders() ### Description Gets a thread-safe, mutable, ordered list of internal and user-defined ValueReaders that are used to read source object values during mapping. ### Method GET ### Endpoint Configuration.getValueReaders() ### Response #### Success Response (200) - **List>** - A list of ValueReader instances. ``` ```APIDOC ## POST Configuration.addValueReader(ValueReader valueReader) ### Description Registers the `valueReader` to use when mapping from instances of types `T`. ### Method POST ### Endpoint Configuration.addValueReader(ValueReader valueReader) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **valueReader** (ValueReader) - Required - The ValueReader to register for type T. ``` -------------------------------- ### TypeMap.addMappings with ExpressionMap Source: https://modelmapper.org/javadoc/org/modelmapper/class-use/ExpressionMap.html Demonstrates how to add custom mappings to a TypeMap using an ExpressionMap. ```APIDOC ## TypeMap.addMappings(ExpressionMap mapper) ### Description Adds a custom mapping configuration to a `TypeMap` using an `ExpressionMap`. This allows for fine-grained control over how properties are mapped between source and destination objects. ### Method `TypeMap.addMappings` ### Parameters #### Request Body - **mapper** (ExpressionMap) - Required - An `ExpressionMap` instance that defines the custom mapping logic for a single property. ```