{"id":30574809,"url":"https://github.com/kilemonn/java-union","last_synced_at":"2025-10-13T13:32:54.693Z","repository":{"id":310509438,"uuid":"1033883918","full_name":"Kilemonn/java-union","owner":"Kilemonn","description":"A simple union implementation in Java/Kotlin.","archived":false,"fork":false,"pushed_at":"2025-08-18T14:15:36.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-29T02:50:31.060Z","etag":null,"topics":["java-library","kotlin","library","reflection","union"],"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/Kilemonn.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2025-08-07T13:49:51.000Z","updated_at":"2025-08-18T14:15:40.000Z","dependencies_parsed_at":"2025-08-18T16:25:38.469Z","dependency_job_id":null,"html_url":"https://github.com/Kilemonn/java-union","commit_stats":null,"previous_names":["kilemonn/java-union"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Kilemonn/java-union","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kilemonn%2Fjava-union","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kilemonn%2Fjava-union/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kilemonn%2Fjava-union/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kilemonn%2Fjava-union/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kilemonn","download_url":"https://codeload.github.com/Kilemonn/java-union/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kilemonn%2Fjava-union/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015312,"owners_count":26085684,"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-13T02:00:06.723Z","response_time":61,"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":["java-library","kotlin","library","reflection","union"],"created_at":"2025-08-28T23:17:58.228Z","updated_at":"2025-10-13T13:32:54.677Z","avatar_url":"https://github.com/Kilemonn.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# java-union\n\n[![CI Build](https://github.com/Kilemonn/java-union/actions/workflows/gradle.yml/badge.svg)](https://github.com/Kilemonn/java-union/actions/workflows/gradle.yml) [![Coverage](.github/badges/jacoco.svg)](https://github.com/Kilemonn/java-union/actions/workflows/gradle.yml)\n\nA simple union implementation in Kotlin allowing you to initialise the union instance with a specific object\nand re-interpret the internal byte array as different types.\nThe byte array cannot be interpreted as a type that is larger than the buffer.\n\n## Quick Start\n\nThis can be included by making sure that you have [JitPack](https://jitpack.io/) setup as a dependency repository within your project. \nYou can refer to the hosted versions of this library at [java-union](https://jitpack.io/#Kilemonn/java-union).\n\n```groovy\nimplementation(\"com.github.Kilemonn:union:0.1.0\")\n```\n\n### Example\n\nThe below example in `Kotlin` stores a `Char` in the `Union` and reads its value out as a `Short`.\n\n```kotlin\nval char = 'c'\nval union = Union(char)\n\n// The union's size is 2 since char's are 2 bytes in the JVM\nassertEquals(2, union.size)\n\n// Will have value 99 because of 'c' having the ASCII value of 99\nval asShort = union.asType(Short::class.java)\nassertEquals(99, asShort)\n\n// This will return null, since the size of an int is 4 bytes, which is larger than the current\n// internal Union buffer (`union.size`)\nval asInt = union.asType(Int::class.java)\nassertNull(asInt)\n```\n\n### Limitations\n\n- Currently only primitive and object primitive types will be serialised into the internal Union buffer.\n- If you are serialising custom types make sure you test it properly incase there are any fields that\ncannot be serialised.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilemonn%2Fjava-union","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkilemonn%2Fjava-union","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilemonn%2Fjava-union/lists"}