{"id":28304393,"url":"https://github.com/harmonysoft-tech/jenome","last_synced_at":"2025-07-30T09:04:55.149Z","repository":{"id":57743150,"uuid":"2129821","full_name":"harmonysoft-tech/jenome","owner":"harmonysoft-tech","description":"Provides convenient access and utility methods for working with statically available information about java generics","archived":false,"fork":false,"pushed_at":"2017-11-26T19:02:07.000Z","size":158,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-18T05:39:26.450Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harmonysoft-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-07-30T19:11:02.000Z","updated_at":"2023-10-29T07:20:13.000Z","dependencies_parsed_at":"2022-09-12T10:50:50.819Z","dependency_job_id":null,"html_url":"https://github.com/harmonysoft-tech/jenome","commit_stats":null,"previous_names":["harmonhsoft-tech/jenome","harmonysoft-tech/jenome","denis-zhdanov/jenome"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/harmonysoft-tech/jenome","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmonysoft-tech%2Fjenome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmonysoft-tech%2Fjenome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmonysoft-tech%2Fjenome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmonysoft-tech%2Fjenome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harmonysoft-tech","download_url":"https://codeload.github.com/harmonysoft-tech/jenome/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmonysoft-tech%2Fjenome/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267842977,"owners_count":24153133,"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-07-30T02:00:09.044Z","response_time":70,"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":[],"created_at":"2025-05-24T00:12:57.096Z","updated_at":"2025-07-30T09:04:55.110Z","avatar_url":"https://github.com/harmonysoft-tech.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Table of Contents\n\n* [1. License](#1-license)\n* [2. Overview](#2-overview)\n* [3. API](#3-overview)\n* [4. Releases](#4-releases)\n\n## 1. License\n\nSee the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).\n\n## 2. Overview\n\nAlthough *Java* generics are rather limited comparing to 'true' generics, it's still possible to extract and use their data in some circumstances:  \n\nHere we are unable to extract type argument's value (*String*) given, say, a reference to the `data` field:   \n```java\nclass MyClass {\n    List data = new ArrayList\u003cString\u003e();\n}\n```\n  \nIn contrast, here we can find out that target type argument's value is *Number*:  \n```java\nclass MyClass implements Comparable\u003cNumber\u003e {\n}\n```\n\nCurrent library helps with type argument values extraction and processing.\n\n## 3. API\n\n**Extract type argument value**\n\nThat functionality is covered by the [TypeArgumentResolver](src/main/java/tech/harmonysoft/oss/jenome/resolve/TypeArgumentResolver.java) interface.  \n\n*Example*\n\nGiven the declarations below:  \n```java\nclass MyInterface\u003cA, B\u003e {}\nclass StringParent\u003cT\u003e implements MyInterface\u003cString, T\u003e {}\nclass Child extends StringParent\u003cLong\u003e {}\n```\n\nWe can find out the following:  \n```java\ntypeArgumentResolver.resolve(MyInterface.class, Child.class, 0) -\u003e String\ntypeArgumentResolver.resolve(MyInterface.class, Child.class, 1) -\u003e Long\n```  \n\nReal-world usage example:  \n\n```java\ninterface Handler\u003cT\u003e {\n    void handle(T input);\n}\n\nclass StringHandler implements Handler\u003cString\u003e {\n    public void handle(String input) {}\n}\n\nclass LongHandler implements Handler\u003cLong\u003e {\n    public void handle(Long input) {}\n}\n\n@Component\nclass Router {\n    \n    private final Map\u003cType, Handler\u003c?\u003e\u003e handlers;\n    \n    @Autowired\n    public Router(Collection\u003cHandler\u003c?\u003e\u003e handlers) {\n        this.handlers = JenomeResolveUtil.byTypeValue(handlers);\n    }\n    \n    public void process(Object data) {\n        Handler handler = handlers.get(data.getClass());\n        if (handler == null) {\n            throw new IllegalArgumentException(String.format(\n                \"No handler is registered for payload of type %s. Known payload mappings: %s\",\n                data.getClass().getSimpleName(), handlers\n            ));\n         }\n         handler.handle(data);\n    }\n}\n```\n\n**Check if one type IS-A another type**\n\nThis functionality is covered by the [TypeComplianceMatcher](src/main/java/tech/harmonysoft/oss/jenome/match/TypeComplianceMatcher.java).  \n\n*Example*\n\n```java\ninterface TestInterface\u003cA, B, C\u003e {}\nclass TestInterfaceImpl\u003cA, B, C\u003e implements TestInterface\u003cA, B, C\u003e {}\nclass SimpleBaseClass implements TestInterface\u003cInteger, Long, String\u003e {}\nclass SimpleMatchedClass extends TestInterfaceImpl\u003cInteger, Long, String\u003e {}\nclass SimpleUnmatchedClass extends TestInterfaceImpl\u003cInteger, Long, Number\u003e {}\n\ntypeComplianceMatcher.match(SimpleBaseClass.class.getGenericInterfaces()[0], SimpleMatchedClass.class.getGenericSuperclass()) -\u003e true\ntypeComplianceMatcher.match(SimpleBaseClass.class.getGenericInterfaces()[0], SimpleUnmatchedClass.class.getGenericSuperclass()) -\u003e false\n```\n\nThis is a must-have functionality when we want to, say, enhance autowiring rules by type argument values. E.g. consider a spring context with beans of the following types:  \n```java\nMyClass\u003cInteger\u003e\nMyClass\u003cLong\u003e\nMyClass\u003cString\u003e\nMyClass\u003cStringBuilder\u003e\n``` \n\nWe'd like to be able to autowire arguments like `Collection\u003cNumber\u003e` (`MyClass\u003cInteger\u003e` and `MyClass\u003cLong\u003e` go here) and `Collection\u003cCharSequence\u003e` (`MyClass\u003cString\u003e` and `MyClass\u003cStringBuilder\u003e` should be provided).  \n\n*Note: right now Spring checks only the base type (`MyClass`) and provides all such beans regarding the type argument's value.*  \n\n## 4. Releases\n\n[Release Notes](RELEASE.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmonysoft-tech%2Fjenome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharmonysoft-tech%2Fjenome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmonysoft-tech%2Fjenome/lists"}