{"id":16895811,"url":"https://github.com/bnorm/piecemeal","last_synced_at":"2025-08-19T05:32:43.693Z","repository":{"id":141875538,"uuid":"565214994","full_name":"bnorm/piecemeal","owner":"bnorm","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-28T02:20:23.000Z","size":227,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-28T03:22:58.964Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bnorm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2022-11-12T17:36:44.000Z","updated_at":"2024-11-28T02:20:27.000Z","dependencies_parsed_at":"2024-04-12T04:47:46.172Z","dependency_job_id":null,"html_url":"https://github.com/bnorm/piecemeal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"bnorm/kotlin-ir-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fpiecemeal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fpiecemeal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fpiecemeal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fpiecemeal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnorm","download_url":"https://codeload.github.com/bnorm/piecemeal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230326804,"owners_count":18209051,"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","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":[],"created_at":"2024-10-13T17:26:23.069Z","updated_at":"2025-08-19T05:32:43.680Z","avatar_url":"https://github.com/bnorm.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# piecemeal-plugin\n\n\u003e **Warning**\n\u003e Work in progress.\n\nKotlin FIR+IR plugin for generating a nested `Mutable` class and associated `build` function.\n\n```kotlin\nimport dev.bnorm.piecemeal.Piecemeal\n\n@Piecemeal\nclass Person(\n    val name: String,\n    val nickname: String? = name,\n    val age: Int = 0,\n)\n```\n\nThe above example will generate the following\n\n```kotlin\n@Piecemeal\nclass Person private constructor(\n    val name: String,\n    val nickname: String? = name,\n    val age: Int = 0,\n) {\n    fun toMutable(): Mutable {\n        val mutable = Mutable()\n        mutable.name = name\n        mutable.nickname = nickname\n        mutable.age = age\n        return mutable\n    }\n\n    inline fun copy(transform: Person.Mutable.() -\u003e Unit): Person {\n        val tmp = this.toMutable()\n        tmp.transform\n        return tmp.build()\n    }\n\n    companion object {\n        @JvmSynthetic // Hide from Java callers who should use Mutable.\n        fun build(builder: Person.Mutable.() -\u003e Unit): Person {\n            return Mutable().apply(builder).build()\n        }\n    }\n\n    class Mutable {\n        @set:JvmSynthetic // Hide 'void' setter from Java.\n        var name: String? = null\n\n        @set:JvmSynthetic // Hide 'void' setter from Java.\n        var nickname: String? = null\n\n        @set:JvmSynthetic // Hide 'void' setter from Java.\n        var age: Int? = null\n\n        fun setName(name: String?): Mutable {\n            this.name = name\n            return this\n        }\n\n        fun setNickname(nickname: String?): Mutable {\n            this.nickname = nickname\n            return this\n        }\n\n        fun setAge(age: Int): Mutable {\n            this.age = age\n            return this\n        }\n\n        fun build(): Person {\n            val name = name ?: throw IllegalStateException(\"Missing required parameter 'name'.\")\n            val nickname = nickname ?: name\n            val age = age ?: 0\n\n            return Person(\n                name = name,\n                nickname = nickname ?: name,\n                age = age,\n            )\n        }\n    }\n}\n```\n\n## Various References\n\n- https://jakewharton.com/public-api-challenges-in-kotlin/\n\n## Development\n\nWhen working with compiler tests, \nit is recommended to use [Kotlin Compiler Test Helper](https://github.com/demiurg906/test-data-helper-plugin).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnorm%2Fpiecemeal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnorm%2Fpiecemeal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnorm%2Fpiecemeal/lists"}