{"id":16215172,"url":"https://github.com/zonia3000/jasmdecor","last_synced_at":"2025-10-19T06:53:15.209Z","repository":{"id":137035343,"uuid":"146356756","full_name":"zonia3000/jasmdecor","owner":"zonia3000","description":"Decorator generator based on Java ASM bytecode manipulation framework","archived":false,"fork":false,"pushed_at":"2018-08-28T20:13:36.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T22:35:59.982Z","etag":null,"topics":["asm","bytecode-manipulation","decorator-pattern","generator","java"],"latest_commit_sha":null,"homepage":null,"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/zonia3000.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":"2018-08-27T21:32:20.000Z","updated_at":"2018-08-28T20:09:10.000Z","dependencies_parsed_at":"2023-04-28T07:24:44.959Z","dependency_job_id":null,"html_url":"https://github.com/zonia3000/jasmdecor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zonia3000/jasmdecor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonia3000%2Fjasmdecor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonia3000%2Fjasmdecor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonia3000%2Fjasmdecor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonia3000%2Fjasmdecor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zonia3000","download_url":"https://codeload.github.com/zonia3000/jasmdecor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonia3000%2Fjasmdecor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001641,"owners_count":26083147,"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-09T02:00:07.460Z","response_time":59,"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":["asm","bytecode-manipulation","decorator-pattern","generator","java"],"created_at":"2024-10-10T11:14:08.836Z","updated_at":"2025-10-09T15:23:28.377Z","avatar_url":"https://github.com/zonia3000.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jasmdecor\n\n**jasmdecor** is a decorator generator based on Java ASM bytecode manipulation framework.\n\nIt takes compiled classes as input and produces compiled decorator classes as output.\n\n## Usage\n\n### Plain decorator\n\n```java\npublic interface Iface {\n\n    void aMethod();\n}\n```\n\n```java\nnew DecoratorGenerator(Iface.class, \"PlainDecorator\").writeDecoratorClass(outputFile);\n```\n\nGenerates the following class:\n\n```java\npublic class PlainDecorator implements Iface {\n\n    private final Iface wrapped;\n\n    public PlainDecorator(Iface wrapped) {\n        this.wrapped = wrapped;\n    }\n\n    @Override\n    public void aMethod() {\n        this.wrapped.aMethod();\n    }\n}\n```\n\n### Template based decorator\n\nStarting from a template class:\n\n```java\npublic class DecoratorFromTemplate {\n\n    private final Iface wrapped;\n\n    public DecoratorFromTemplate(Iface wrapped) {\n        this.wrapped = wrapped;\n    }\n\n    public void newMethod() {\n        System.out.println(\"This is a new method!\");\n    }\n}\n```\n\n**Please note**: it is not necessary for the template implementing the interface, but it is mandatory setting the wrapped field and name it `wrapped`. The template can introduce new methods or override methods of the wrapped instance class. The template can also be abstract if you need to add the `implements` part on the class definition without implementing all the methods.\n\n\n```java\nnew DecoratorGenerator(Iface.class, DecoratorFromTemplate.class).writeDecoratorClass(outputFile);\n```\n\nGenerates the following class:\n\n```java\npublic class DecoratorFromTemplate implements Iface {\n\n    private final Iface wrapped;\n\n    public DecoratorFromTemplate(Iface wrapped) {\n        this.wrapped = wrapped;\n    }\n\n    @Override\n    public void aMethod() {\n        this.wrapped.aMethod();\n    }\n\n    public void newMethod() {\n        System.out.println(\"This is a new method!\");\n    }\n}\n```\n\n### CLI\n\nThis project contains also a command line interface.\n\n    java -jar jasmdecor.jar \u003cclass-to-decorate\u003e \u003cdecorator-name-or-template\u003e \u003coutput-file\u003e\n\nExample for a plain decorator without additional classes:\n\n    java -jar jasmdecor.jar java.sql.PreparedStatement PSDecor PSDecor.class\n\nExample for a decorator from template using additional classes (you have to add them to the classpath):\n\n    java -cp \".:jasmdecor.jar\" net.zonia3000.jasmdecor.CLI Iface DecoratorFromTemplate DecoratorFromTemplate.class\n\n(on Windows replace `:` with `;`)\n\n## Additional notes\n\n* Decorators can also be generated from non-final classes\n* Final, native and static methods will be skipped\n* Class inheritance is considered, so delegated methods of all the class hierarchy will be built (including decorable `Object` methods).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonia3000%2Fjasmdecor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzonia3000%2Fjasmdecor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonia3000%2Fjasmdecor/lists"}