{"id":19260684,"url":"https://github.com/evant/value-processor","last_synced_at":"2025-04-21T16:32:08.544Z","repository":{"id":57736732,"uuid":"122000827","full_name":"evant/value-processor","owner":"evant","description":"Helper for creating annotation processors that create/read value objects.","archived":false,"fork":false,"pushed_at":"2020-06-14T22:56:01.000Z","size":77,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T14:38:16.624Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/evant.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}},"created_at":"2018-02-18T23:36:12.000Z","updated_at":"2021-02-10T17:19:21.000Z","dependencies_parsed_at":"2022-08-24T02:51:09.136Z","dependency_job_id":null,"html_url":"https://github.com/evant/value-processor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evant%2Fvalue-processor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evant%2Fvalue-processor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evant%2Fvalue-processor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evant%2Fvalue-processor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evant","download_url":"https://codeload.github.com/evant/value-processor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250091020,"owners_count":21373302,"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-09T19:22:30.890Z","updated_at":"2025-04-21T16:32:08.228Z","avatar_url":"https://github.com/evant.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# value-processor\nHelper for creating annotation processors that create/read value objects.\n\n## Download\n\n### Gradle\n\n```groovy\ndependencies {\n  compile 'me.tatarka.value:value-processor:0.2'\n}\n```\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eme.tatarka.value\u003c/groupId\u003e\n  \u003cartifactId\u003evalue-processor\u003c/artifactId\u003e\n  \u003cversion\u003e0.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\nFirst you create a `ValueCreator` with the processing environment.\n\n```java\npublic class MyProcessor extends AbstractProcessor {\n\n    private ValueCreator valueCreator;\n\n    @Override\n    public synchronized void init(ProcessingEnvironment processingEnv) {\n        super.init(processingEnv);\n        valueCreator = new ValueCreator(processingEnv);\n    }\n```\n\nThen create a `Value` from an `Element`. There are various methods based on what you have annotated. For example, the below creates it from the target class.\n\n```java\n    @Override\n    public boolean process(Set\u003c? extends TypeElement\u003e annotations, RoundEnvironment roundEnv) {\n        for (TypeElement annotation : annotations) {\n            Set\u003c? extends Element\u003e elements = roundEnv.getElementsAnnotatedWith(annotation);\n            for (Element element : elements) {\n               try {\n                   Value value = valueCreator.fromClass((TypeElement) element);\n               } catch (ElementException e) {\n                   e.printMessage(messenger);\n               }\n            }\n        }\n        return false;\n    }\n```\n\nYou can then iterate through the properties to generate your code.\n\n```java\n// all properties\nfor (Property\u003c?\u003e property : value.getProperties()) {\n    ...\n}\n// of a specific kind\nfor (Property.Getter getter : value.getProperties().getGetters()) {\n    ...\n}\n```\n\n## Supported Classes\nNote: Classes are expected to be treated as immutable. This meas you can only create instances with properties or read properties on and instance.\n\n### Fields\n```java\npublic class Foo {\n    public String bar;\n}\n```\n### Getters\n```java\npublic class Foo {\n    public String getBar() { ... }\n}\n```\n### Constructor Params\n```java\npublic class Foo {\n    public Foo(String bar) { ... }\n}\n```\n### Factory Method Params\n```java\npublic static Foo createFoo(String bar) { ... }\n```\n### Builder\n```java\npublic class FooBuilder {\n    public FooBuilder setBar(String bar) { ... }\n    public Foo build() { ... }\n}\n```\n### Builder Constructor Params\n```java\npublic class FooBuilder {\n    public FooBuilder(String bar) { ... }\n    public Foo build() { ... }\n}\n```\n### Builder Factory Params\n```java\npublic static FooBuilder builder(String bar) { ... }\n```\n### Kotlin Data Classes\n```kotlin\ndata class Foo(val bar: String)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevant%2Fvalue-processor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevant%2Fvalue-processor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevant%2Fvalue-processor/lists"}