A powerful IntelliJ IDEA plugin that simplifies the process of generating mapping functions for Kotlin data classes. Designed to boost developer productivity by automating repetitive code generation tasks, particularly when converting between DTO and domain models.
- Generate Mapping Functions: Automatically generate mapping functions between two Kotlin data classes.
- Support for Nested Classes: Handles nested data classes recursively, ensuring accurate and clean mapping.
- Customizable: Configure mapping behavior through the settings panel.
- Optimized for Kotlin: Fully compatible with both K1 and K2 Kotlin compilers.
- Simple Integration: Easily accessible from the editor's context menu.
- Android Studio — Jellyfish | 2023.3.1+
- IntelliJ IDEA Community — 2023.3+
- IntelliJ IDEA Ultimate — 2023.3+
- Aqua — 2024.1.1+
We want your feedback!
- Vote on feature requests. Votes help us drive prioritization of features
- Request a new feature
- Ask a question
- File an issue
- Code contributions. See our contributing guide for how to get started.
- Download the plugin from the JetBrains Plugin Marketplace.
- Install it directly in IntelliJ IDEA:
- Open
File > Settings > Plugins
. - Search for "Kotlin Data Mapper".
- Click "Install" and restart your IDE.
- Open
- Open any Kotlin file containing data classes.
- Right-click inside the editor and select Generate Mapping Function from the context menu.
- Select the source and target classes in the provided UI dialog.
- The mapping function will be generated and inserted into your project.
The plugin provides a settings panel to customize its behavior:
- Open
File > Settings > Tools > Kotlin Data Mapper Settings
. - Adjust the available options to suit your needs.
- Save and apply your changes.
package ir.mohsenafshar.feature.data
data class UserDTO(
val name: String,
val fam: String,
val age: Int,
val address: AddressDTO
)
data class AddressDTO(
val city: String,
val apt: String,
val streetInfo: StreetInfoDTO,
)
data class StreetInfoDTO(
val name: String,
val number: Int,
)
package ir.mohsenafshar.feature.domain
data class User(
val age: Int,
val fam: String,
val address: Address
)
data class Address(
val city: String,
val apt: String,
val streetInfo: StreetInfo,
)
data class StreetInfo(
val name: String,
val number: Int,
)
fun UserDTO.toUser(): User {
return User(
age = this.age,
fam = this.fam,
address = Address(
city = this.address.city,
apt = this.address.apt,
streetInfo = StreetInfo(name = this.address.streetInfo.name, number = this.address.streetInfo.number)
)
)
}
- GitHub Repository: https://github.com/mohsenafshar/kotlin-data-mapper
- Plugin on JetBrains Marketplace: https://plugins.jetbrains.com/plugin/25820-kotlin-data-mapper
The plugin is distributed according to the terms outlined in our LICENSE.