{"id":18046802,"url":"https://github.com/blipinsk/data-class-builder","last_synced_at":"2025-10-24T05:41:32.481Z","repository":{"id":90321615,"uuid":"226739683","full_name":"blipinsk/data-class-builder","owner":"blipinsk","description":"🏗 Automatically generating builders 👷‍♂️for Kotlin data classes","archived":false,"fork":false,"pushed_at":"2020-06-17T09:14:32.000Z","size":1548,"stargazers_count":18,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T05:02:18.678Z","etag":null,"topics":["annotation-processor","annotations","data-class","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blipinsk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-08T22:15:05.000Z","updated_at":"2024-11-29T23:38:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"e38902bc-339d-4b10-a929-0c7142c5a11c","html_url":"https://github.com/blipinsk/data-class-builder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/blipinsk/data-class-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blipinsk%2Fdata-class-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blipinsk%2Fdata-class-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blipinsk%2Fdata-class-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blipinsk%2Fdata-class-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blipinsk","download_url":"https://codeload.github.com/blipinsk/data-class-builder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blipinsk%2Fdata-class-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280747374,"owners_count":26383946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annotation-processor","annotations","data-class","kotlin"],"created_at":"2024-10-30T19:09:09.692Z","updated_at":"2025-10-24T05:41:32.476Z","avatar_url":"https://github.com/blipinsk.png","language":"Kotlin","readme":"![Image](/img/2200x660.png)\n  \n[ ![bintray](https://img.shields.io/bintray/v/blipinsk/maven/data-class-builder?color=success\u0026label=bintray) ](https://bintray.com/blipinsk/maven/data-class-builder/_latestVersion) \n[ ![maven-central](https://img.shields.io/maven-central/v/com.bartoszlipinski/data-class-builder?label=maven-central) ](https://search.maven.org/search?q=g:com.bartoszlipinski%20AND%20a:data-class-builder)\n\n\u003c/p\u003e\n\n🏗 Automatically generating builders :construction_worker: for Kotlin `data classes`.\n\n\u003csub\u003e\u003csup\u003e\u003cb\u003e\u003ci\u003e(incremental)\u003c/b\u003e\u003c/i\u003e\u003c/sup\u003e\u003c/sub\u003e\n  \nUsage  \n=====  \n  \n*For a working usage of this library see the `sample/` module.*  \n  \n  \n 1. (*optional - for **Android** projects*) add to your app's `build.gradle`:  \n    ```groovy  \n    android {  \n        kotlinOptions.jvmTarget = '1.8'  \n    }  \n    ```  \n  \n 2. Add to `@DataClassBuilder` annotation your `data class`\n    ```kotlin\n    @DataClassBuilder  \n    data class User(  \n        val name: String = \"Anonymous\",  \n        val age: Int,  \n        val photoUrl: String? = null  \n    ) {  \n        companion object //\u003c-- OPTIONAL companion object\n    }  \n    ```  \n       \n 3. Use the generated builder to create your `data class`:\n    ```kotlin\n    //1. Java-style builder\n    val jane = dataClassBuilder(User::class)\n        .name(\"Jane\")\n        .age(30)\n        .build()\n    ```\n    or\n    ```kotlin\n    //2. Kotlin DSL builder\n    val jane = buildDataClass(User::class) {\n        name = \"Jane\"\n        age = 30\n    }\n    ```\n    or\n    ```kotlin\n    //3. Java-style builder through companion (generated if companion is present)\n    val jane = User.dataClassBuilder()\n        .name(\"Jane\")\n        .age(30)\n        .build()\n    ```\n    or\n    ```kotlin\n    //4. Kotlin DSL builder through companion (generated if companion is present)\n    val jane = User.buildDataClass {\n        name = \"Jane\"\n        age = 30\n    }\n    ```\n\nJava interop\n-----------\nFor easy interoperation with Java code add this `companion object` to your `data class`:\n```kotlin\n@DataClassBuilder  \ndata class User(  \n    val name: String = \"Anonymous\",  \n    val age: Int,  \n    val photoUrl: String? = null  \n) {  \n    companion object {\n        @JvmStatic\n        fun builder() = dataClassBuilder(User::class) //NOT specifying return type explicitly on purpose\n    }\n}  \n```  \n(_something like this might be generated by the library in one of the future implementations_)\n  \n  \nIncluding In Your Project  \n-------------------------  \nAdd in your `build.gradle`:  \n```xml  \nrepositories {  \n    maven { url 'https://dl.bintray.com/blipinsk/maven/' }  \n}  \n  \ndependencies {  \n    kapt \"com.bartoszlipinski:data-class-builder-compiler:0.1.0\"  \n    implementation \"com.bartoszlipinski:data-class-builder:0.1.0\"  \n}  \n```  \n\n\nImportant\n---------\nThe presence of `data class` parameters is verified **in runtime**.\n\nE.g.\n\n 1. For `data class`:\n    ```kotlin\n    @DataClassBuilder  \n    data class User(  \n        val name: String = \"Anonymous\",  \n        val age: Int // \u003c-- no default value specified\n    )\n    ```\n    \n 2. When creating:\n    ```kotlin\n    buildDataClass(User::class) {\n        name = \"John\"\n        // not setting the necessary `age`\n    }\n    ```\n\n3. :point_up: this will crash :boom: **in runtime** :point_up:\n  \nDeveloped by  \n============  \n * Bartosz Lipiński  \n  \nLicense  \n=======  \n  \n    Copyright 2020 Bartosz Lipiński  \n      \n    Licensed under the Apache License, Version 2.0 (the \"License\");  \n    you may not use this file except in compliance with the License.  \n    You may obtain a copy of the License at  \n  \n       http://www.apache.org/licenses/LICENSE-2.0  \n  \n    Unless required by applicable law or agreed to in writing, software  \n    distributed under the License is distributed on an \"AS IS\" BASIS,  \n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  \n    See the License for the specific language governing permissions and  \n    limitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblipinsk%2Fdata-class-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblipinsk%2Fdata-class-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblipinsk%2Fdata-class-builder/lists"}