{"id":20474030,"url":"https://github.com/drewhamilton/poko","last_synced_at":"2025-04-06T01:08:38.287Z","repository":{"id":38188775,"uuid":"243601035","full_name":"drewhamilton/Poko","owner":"drewhamilton","description":"A Kotlin compiler plugin that generates equals, hashCode, and toString for plain old Kotlin objects in public APIs.","archived":false,"fork":false,"pushed_at":"2024-04-13T00:41:14.000Z","size":1099,"stargazers_count":282,"open_issues_count":15,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-14T09:18:46.582Z","etag":null,"topics":["data-api-generator","data-class","data-generator","extra-care","ir","kotlin-compiler-plugin"],"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/drewhamilton.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}},"created_at":"2020-02-27T19:37:36.000Z","updated_at":"2024-04-17T18:47:01.641Z","dependencies_parsed_at":"2023-10-12T13:39:17.405Z","dependency_job_id":"9c6c622a-3082-481c-a22c-e007db88bd99","html_url":"https://github.com/drewhamilton/Poko","commit_stats":null,"previous_names":["drewhamilton/extracare"],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewhamilton%2FPoko","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewhamilton%2FPoko/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewhamilton%2FPoko/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewhamilton%2FPoko/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drewhamilton","download_url":"https://codeload.github.com/drewhamilton/Poko/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419860,"owners_count":20936012,"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":["data-api-generator","data-class","data-generator","extra-care","ir","kotlin-compiler-plugin"],"created_at":"2024-11-15T14:27:38.305Z","updated_at":"2025-04-06T01:08:38.282Z","avatar_url":"https://github.com/drewhamilton.png","language":"Kotlin","readme":"# Poko\n[![CI status badge](https://github.com/drewhamilton/Poko/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/drewhamilton/Poko/actions/workflows/ci.yml?query=branch%3Amain)\n\nPoko is a Kotlin compiler plugin that makes writing and maintaining data model classes for public\nAPIs easy. Like with normal Kotlin data classes, all you have to do is provide properties in your\nclass's primary constructor. With the `@Poko` annotation, this compiler plugin automatically\ngenerates `toString`, `equals`, and `hashCode` functions. Poko is compatible with all Kotlin\nMultiplatform targets.\n\n## Use\nMark your class as a `@Poko class` instead of a `data class`:\n```kotlin\n@Poko class MyData(\n    val int: Int,\n    val requiredString: String,\n    val optionalString: String?,\n)\n```\n\nAnd reap the benefits of a readable `toString` and working `equals` and `hashCode`. Unlike normal\ndata classes, no `copy` or `componentN` functions are generated.\n\nLike normal data classes, Poko classes must have at least one property in their primary constructor.\nNon-property parameters in the primary constructor are ignored, as are non-constructor properties.\nAny of the three generated functions can be overridden manually, in which case Poko will not\ngenerate that function but will still generate the non-overridden functions. Using array properties\nis not recommended, and if they are used, it is recommended to override `equals` and `hashCode`\nmanually.\n\n### Annotation\nBy default, the `dev.drewhamilton.poko.Poko` annotation is used to mark classes for Poko generation.\nIf you prefer, you can create a different annotation and supply it to the Gradle  plugin.\n\n```groovy\napply plugin: \"dev.drewhamilton.poko\"\npoko {\n  pokoAnnotation.set \"com/example/MyData\"\n}\n```\n\nNested annotations mentioned below can optionally be added with the same name to the base annotation\nand used for their respective features. For example, `@MyData.ReadArrayContent` will cause the\nannotated property's contents to be used in the Poko-generated functions.\n\n### Arrays\nBy default, Poko does nothing to inspect the contents of array properties. [This aligns with the\nbehavior of data classes](https://blog.jetbrains.com/kotlin/2015/09/feedback-request-limitations-on-data-classes/#Appendix.Comparingarrays).\n\nPoko consumers can change this behavior on a per-property basis with the `@Poko.ReadArrayContent`\nannotation. On properties of a typed array type, this annotation will generate a `contentDeepEquals`\ncheck. On properties of a primitive array type, this annotation will generate a `contentEquals`\ncheck. And on properties of type `Any` or of a generic type, this annotation will generate a `when`\nstatement that disambiguates the many array types at runtime and uses the appropriate\n`contentDeepEquals` or `contentEquals` check. In all cases, the corresponding content-based\n`hashCode` and `toString` are generated for the property as well.\n\nUsing arrays as properties in data types is not generally recommended: arrays are mutable, and\nmutating data can affect the results of `equals` and `hashCode` over time, which is generally\nunexpected. For this reason, `@Poko.ReadArrayContent` should only be used in very\nperformance-sensitive APIs.\n\n### Skipping properties\n\nIt is sometimes useful to omit some properties from consideration when generating the Poko\nfunctions. This can be done with the experimental `@Poko.Skip` annotation. Properties with this\nannotation will be excluded from all three generated functions. For example:\n\n```kotlin\n@Poko class Data(\n    val id: String,\n    @Poko.Skip val callback: () -\u003e Unit,\n) : CircuitUiState\n\nData(\"a\", { println(\"a\") }) == Data(\"a\", { println(\"not a\") }) // yields `true`\n```\n\n### Download\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.drewhamilton.poko/poko-compiler-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.drewhamilton.poko/poko-compiler-plugin)\n\nPoko is available on Maven Central. It is experimental, and the API may undergo breaking changes\nbefore version 1.0.0. Kotlin compiler plugins in general are experimental and new versions of Kotlin\nmight break something in this compiler plugin.\n\nSince the Kotlin compiler has frequent breaking changes, different versions of Kotlin are\nexclusively compatible with specific versions of Poko.\n\n| Kotlin version  | Poko version |\n|-----------------|--------------|\n| 2.1.0 – 2.1.20  | 0.18.5       |\n| 2.0.0 – 2.0.21  | 0.17.2       |\n| 1.9.0 – 1.9.24  | 0.15.3       |\n| 1.8.20 – 1.8.22 | 0.13.1       |\n| 1.8.0 – 1.8.10  | 0.12.0       |\n| 1.7.0 – 1.7.21  | 0.11.0       |\n| 1.6.20 – 1.6.21 | 0.10.0       | \n| 1.6.0 – 1.6.10  | 0.9.0        |\n| 1.5.0 – 1.5.31  | 0.8.1        |\n| 1.4.30 – 1.4.32 | 0.7.4        |\n| 1.4.20 – 1.4.21 | 0.5.0*       |\n| 1.4.0 – 1.4.10  | 0.3.1*       |\n| 1.3.72          | 0.2.4*       |\n\nSnapshots of the development version are available in [Sonatype's Snapshots\nrepository](https://oss.sonatype.org/#view-repositories;snapshots~browsestorage).\n\nReleases are signed with [this key](https://keyserver.ubuntu.com/pks/lookup?search=09939C73246B4BA7444CAA453D002DBC5EA9615F\u0026fingerprint=on\u0026op=index).\n```\npub   rsa4096 2020-02-02\n      09939C73246B4BA7444CAA453D002DBC5EA9615F\nuid   Drew Hamilton \u003cdrew.hamilton.0@gmail.com\u003e\nsig   3D002DBC5EA9615F 2020-02-02\n```\n\nTo use Poko, apply the Gradle plugin in your project:\n```kotlin\n// Root project:\nplugins {\n    id(\"dev.drewhamilton.poko\") apply false\n}\n\n// Per module:\nplugins {\n    id(\"dev.drewhamilton.poko\")\n}\n```\n\n\\*Versions prior to 0.7.0 use plugin name `dev.drewhamilton.extracare`.\n\n## License\n```\nCopyright 2020 Drew Hamilton\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewhamilton%2Fpoko","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrewhamilton%2Fpoko","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewhamilton%2Fpoko/lists"}