{"id":21387186,"url":"https://github.com/sshtools/simjac","last_synced_at":"2025-03-16T12:20:23.736Z","repository":{"id":84133136,"uuid":"605528342","full_name":"sshtools/simjac","owner":"sshtools","description":"Simple JSON Configuration","archived":false,"fork":false,"pushed_at":"2024-01-27T00:36:10.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-23T00:13:31.384Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/sshtools.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}},"created_at":"2023-02-23T10:53:50.000Z","updated_at":"2023-02-23T10:58:16.000Z","dependencies_parsed_at":"2024-01-27T02:00:34.767Z","dependency_job_id":null,"html_url":"https://github.com/sshtools/simjac","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshtools%2Fsimjac","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshtools%2Fsimjac/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshtools%2Fsimjac/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshtools%2Fsimjac/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshtools","download_url":"https://codeload.github.com/sshtools/simjac/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243865425,"owners_count":20360442,"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-11-22T12:12:04.918Z","updated_at":"2025-03-16T12:20:23.702Z","avatar_url":"https://github.com/sshtools.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simjac\n\nA small Java library used by various other JAdaptive projects that can be used to bind a \nJSON structure to Java objects for the purposes of application configuration. \n\nRather than using reflection, it uses a builder pattern along with `Supplier\u003c?\u003e` and `Consumer\u003c?\u003e`\nto model the binding. \n\n * Uses no reflection, so ideal for configuration free usage with Graal native images.\n * Finds the best location to place to JSON based on OS (currently has special behaviour for Windows, Linux and Mac OS.\n * `USER` or `GLOBAL` scopes, or `CUSTOM` locations.\n * A single JSON object's attributes may be bound to multiple unrelated attributes of Java objects,\n   useful for binding JSON data to JavaFX UI for example.\n \n## TODO\n\n * Binding of `List`, `Map` and complex object types.\n * Custom storage backends.\n \n## Example\n\n```java\npackage test;\nimport static com.sshtools.simjac.binding.AttrBindBuilder.*;\nimport com.sshtools.simjac.store.ConfigurationStoreBuilder;\n\npublic class Test {\n\t\n\tpublic static void main(String[] args) {\n\t\tvar t = new TestObject();\n\t\tvar store = ConfigurationStoreBuilder.builder().\n\t\t\t\twithName(\"configuration\").\n\t\t\t\twithApp(\"SimjacTest\").\n\t\t\t\twithoutFailOnMissingBinds().\n\t\t\t\twithBinding(\n\t\t\t\t\t\txstring(\"name\", t::setName, t::getName).build(),\n\t\t\t\t\t\txinteger(\"value\", t::setValue, t::getValue).build(),\n\t\t\t\t\t\txboolean(\"selected\", t::setSelected, t::isSelected).build(),\n\t\t\t\t\t\txshort(\"size\", t::setSize, t::getSize).build(),\n\t\t\t\t\t\txbyte(\"flag\", t::setFlag, t::getFlag).build(),\n\t\t\t\t\t\txlong(\"time\", t::setTime, t::getTime).build(),\n\t\t\t\t\t\txdouble(\"ratio\", t::setRatio, t::getRatio).build(),\n\t\t\t\t\t\txfloat(\"factor\", t::setFactor, t::getFactor).build(),\n\t\t\t\t\t\txchar(\"marker\", t::setMarker, t::getMarker).build()\n\t\t\t\t\t\t).\n\t\t\t\tbuild();\n\n\t\tstore.store();\n\t\t\n\t\t// or\n\n\t\tstore.retrieve();\n\t}\n\t\n\tstatic class TestObject {\n\t\tprivate String name;\n\t\tprivate int value;\n\t\tprivate boolean selected;\n\t\tprivate short size;\n\t\tprivate byte flag;\n\t\tprivate long time;\n\t\tprivate double ratio;\n\t\tprivate float factor;\n\t\tprivate char marker;\n\t\t\n\t\tpublic byte getFlag() {\n\t\t\treturn flag;\n\t\t}\n\n\t\tpublic void setFlag(byte flag) {\n\t\t\tthis.flag = flag;\n\t\t}\n\n\t\tpublic long getTime() {\n\t\t\treturn time;\n\t\t}\n\n\t\tpublic void setTime(long time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic double getRatio() {\n\t\t\treturn ratio;\n\t\t}\n\n\t\tpublic void setRatio(double ratio) {\n\t\t\tthis.ratio = ratio;\n\t\t}\n\n\t\tpublic float getFactor() {\n\t\t\treturn factor;\n\t\t}\n\n\t\tpublic void setFactor(float factor) {\n\t\t\tthis.factor = factor;\n\t\t}\n\n\t\tpublic char getMarker() {\n\t\t\treturn marker;\n\t\t}\n\n\t\tpublic void setMarker(char marker) {\n\t\t\tthis.marker = marker;\n\t\t}\n\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\t\t\n\t\tpublic void setValue(int value) {\n\t\t\tthis.value = value;\n\t\t}\n\t\t\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\t\t\n\t\tpublic int getValue() {\n\t\t\treturn value;\n\t\t}\n\t\t\n\t\tpublic void setSelected(boolean selected) {\n\t\t\tthis.selected = selected;\n\t\t}\n\t\t\n\t\tpublic boolean isSelected() {\n\t\t\treturn selected;\n\t\t}\n\t\t\n\t\tpublic void setSize(short size) {\n\t\t\tthis.size = size;\n\t\t}\n\t\t\n\t\tpublic short getSize() {\n\t\t\treturn size;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn \"TestObject [name=\" + name + \", value=\" + value + \", selected=\" + selected + \", size=\" + size\n\t\t\t\t\t+ \", flag=\" + flag + \", time=\" + time + \", ratio=\" + ratio + \", factor=\" + factor + \", marker=\"\n\t\t\t\t\t+ marker + \"]\";\n\t\t}\n\t}\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshtools%2Fsimjac","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshtools%2Fsimjac","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshtools%2Fsimjac/lists"}