All Projects → jffiorillo → jvmbuilder

jffiorillo / jvmbuilder

Licence: other
A source code generator for Kotlin data classes to automatically create a Builder class.

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to jvmbuilder

ColdStorage
Lightweight data loading and caching library for android
Stars: ✭ 39 (+143.75%)
Mutual labels:  annotation-processor, kapt
Kotlin-Annotation-Processor
Annotation Processor Sample in Kotlin
Stars: ✭ 19 (+18.75%)
Mutual labels:  annotation-processor, kapt
Androidannotations
Fast Android Development. Easy maintainance.
Stars: ✭ 11,167 (+69693.75%)
Mutual labels:  annotation-processor
extclassgenerator
Ext JS code generator. Creating model js classes from java classes
Stars: ✭ 14 (-12.5%)
Mutual labels:  annotation-processor
Moxy
Moxy is MVP library for Android with incremental annotation processor and ktx features
Stars: ✭ 234 (+1362.5%)
Mutual labels:  annotation-processor
Beanknife
An annotation processor library to automatically generate the data transfer objects (DTO).
Stars: ✭ 163 (+918.75%)
Mutual labels:  annotation-processor
Kotlin Compile Testing
A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Stars: ✭ 245 (+1431.25%)
Mutual labels:  annotation-processor
Flownav
Annotation processor that provides better navigation on android multi-modules projects 🛳.
Stars: ✭ 122 (+662.5%)
Mutual labels:  annotation-processor
navigator
Annotation processor that eliminates navigation and Bundle boilerplate
Stars: ✭ 13 (-18.75%)
Mutual labels:  annotation-processor
Ulfberht
🗡️ A small but powerful & opinionated DI library. Written in Kotlin, and powered by annotation processing.
Stars: ✭ 234 (+1362.5%)
Mutual labels:  annotation-processor
green-annotations
An Android Annotations plugin to support Green Robot.
Stars: ✭ 21 (+31.25%)
Mutual labels:  annotation-processor
Transfuse
💉 Transfuse - A Dependency Injection and Integration framework for Google Android
Stars: ✭ 226 (+1312.5%)
Mutual labels:  annotation-processor
Placeholderview
This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->
Stars: ✭ 2,104 (+13050%)
Mutual labels:  annotation-processor
Shortbread
Android library that creates app shortcuts from annotations
Stars: ✭ 1,803 (+11168.75%)
Mutual labels:  annotation-processor
copydynamic
Prototype of generating `copyDynamic` extension functions for kotlin data classes
Stars: ✭ 57 (+256.25%)
Mutual labels:  kapt
Bulldog
Android library to simplify reading and writing to SharedPreferences, never write code like this anymore prefs.edit().putString("someKey","someString").apply()
Stars: ✭ 133 (+731.25%)
Mutual labels:  annotation-processor
Mpapt
🔧 Kotlin Native/JS/JVM Annotation Processor library for Kotlin compiler plugins
Stars: ✭ 213 (+1231.25%)
Mutual labels:  annotation-processor
Moshix
Moshi Extensions
Stars: ✭ 243 (+1418.75%)
Mutual labels:  annotation-processor
aptk
A toolkit project to enable you to build annotation processors more easily
Stars: ✭ 28 (+75%)
Mutual labels:  annotation-processor
MethodScope
Reduce repetitive inheritance works in OOP world using @MethodScope.
Stars: ✭ 33 (+106.25%)
Mutual labels:  annotation-processor

JvmBuilder

Download

A source code generator for Kotlin data classes to automatically create a Builder class.

How to use JvmBuilder

When annotating a Kotlin data class with @JvmBuilder

@JvmBuilder
data class Test(val foo: Int = 1, val bar: String)

The following class is generated

// Code auto-generated by JvmBuilder. Do not edit.
package com.example

import kotlin.Int
import kotlin.String

class JvmBuilder_Test {
    private var foo: Int? = null

    private var bar: String? = null

    fun foo(foo: Int): JvmBuilder_Test {
        this.foo = foo
        return this
    }

    fun bar(bar: String): JvmBuilder_Test {
        this.bar = bar
        return this
    }

    fun build(): Test {
        var result = com.example.Test(bar = this.bar!!)
        result = result.copy(foo = this.foo ?: result.foo)
        return result
    }
}

This provides a Builder class that can be used in Java to create your Kotlin Test data class using the default values and following a Builder Pattern.

The following Java code generates a Test instance with foo = 1 (taking the 1 from the default Kotlin constructor) and bar = "bar".

new Jvm_Builder().bar("bar").build()

Gradle

Gradle users should add the dependencies in their build.gradle file:

dependencies {
  implementation "io.github.jffiorillo:jvmbuilder-annotations:<latest_version>"
  kapt "io.github.jffiorillo:jvmbuilder:<latest_version>"
}

Maven

Maven users should add the dependencies in their pom.xml file:

<dependency>
  <groupId>io.github.jffiorillo</groupId>
  <artifactId>jvmbuilder-annotations</artifactId>
  <version>{latest_version}</version>
</dependency>
<dependency>
  <groupId>io.github.jffiorillo</groupId>
  <artifactId>jvmbuilder</artifactId>
  <version>{latest_version}</version>
  <scope>provided</scope>
</dependency>

Benefit

  • In order to have a good Kotlin interoperability with Java, you can use this tool to generate automatically generate Builders for your data classes that are accessible from Java consumers.
  • The time of executing the annotation processor is really slow because uses the kotlin-metadata instead of reflection.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].