A plugin for IntelliJ IDEA that auto-generates builder classes for your domain data classes, and saves you a lot of typing.
This plugin for IntelliJ IDEA provides a quick way to implement a (simplified) Builder pattern for a given Kotlin data class. It will automatically generate a boilerplate builder class with a build()
method that creates a valid instance of the target data class, and withX()
methods that allow to manually set all primary constructor properties of the constructed object.
- Automatic boilerplate builder class generation
- Pre-set default values for any primitive, nullable and collection properties
- Generated
withoutX()
methods for nullable properties - Customizable builder class and method names via plugin configuration
- Selectable placement of builder class in production or test sources
- Automatic wrapping/unwrapping of "wrapped primitive"-type properties
- Detection and usage of existing builders for property types
- Generated methods to add items to collection properties
Download the latest kotlin-builder-generator-plugin-<VERSION>.zip
from the releases page.
Install in your IntelliJ instance via File -> Settings -> Plugins -> [...] -> Install Plugin from Disk
.
Configure to your liking via File -> Settings -> Tools -> Kotlin Builder Generator
.
Usage: position cursor on the name of a Kotlin data class, open the Generate
menu and select Builder Class
.
- Kotlin (written in Kotlin, for Kotlin)
- IntelliJ Platform SDK (base SDK for any IntelliJ plugin)
- KotlinPoet (Kotlin code generation)
- Gradle (build tool)
- JUnit 4 (tests)