Mappie
Kotlin object mapping made simple and quick.
Install / Use
/learn @Mr-Mappie/MappieREADME
Mappie
Mappie is a Kotlin Multiplatform compiler plugin which generates code to simplify developing object mapping code. Writing object mapping code is often a mind-numbing and error-prone task. Reducing this development effort will lead to a more pleasant programming experience, and less risk of bugs.
Mappie offers the following advantages:
- All code is generated at compile-time, without the need for any reflection at runtime. Making the generated code have the same runtime performance as if one would write the object mapping code manually.
- You write Kotlin code instead of String references, allowing your IDE to support you with automatic refactorings and auto-complete.
- Fully designed with Kotlin in mind, making the code idiomatic and completely type-safe.
- Mappie is easy to use and infers as much as possible.
- Flawless compatibility with other platforms, such as Java types.
- Error messages are informative and suggest concrete actions.
Visit the project documentation for more in-depth information.
Example
The following snippet provides a minimal peek into the idiomatic style of Mappie. Suppose we have the data class Person
which we want to map to the data class PersonDto
data class Person(
val name: String,
val surname: String,
val age: Int,
)
data class PersonDto(
val name: String,
val age: Int,
)
We can achieve generating such a mapper using the following object mapper.
object PersonToPersonDtoMapper : ObjectMappie<Person, PersonDto>() {
override fun map(from: Person) = mapping {
to::name fromValue "${from.name} ${from.surname}"
}
}
Usage
Mappie can be used via Gradle and Maven.
Gradle
Mappie can be used via Gradle, it can be applied by adding the following snippet to your build.gradle.kts file.
plugins {
id("tech.mappie.plugin") version "version"
}
For more details, visit the gradle setup documentation.
Maven
Mappie can be used via Maven, it can be applied by adding the following snippet to your pom.xml file.
...
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>...</version>
<configuration>
<compilerPlugins>
<compilerPlugin>mappie</compilerPlugin>
</compilerPlugins>
<pluginOptions>
...
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>tech.mappie</groupId>
<artifactId>mappie-maven-plugin</artifactId>
<version>version</version>
</dependency>
</dependencies>
</plugin>
...
We must also add the mappie-api dependency. For example, for the JVM
<dependency>
<groupId>tech.mappie</groupId>
<artifactId>mappie-api-jvm</artifactId>
<version>version</version>
</dependency>
For more details, visit the maven setup documentation.
Related Skills
node-connect
341.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.5kCommit, push, and open a PR
