{"id":20340389,"url":"https://github.com/toolisticon/bean-builder","last_synced_at":"2025-04-11T23:22:16.721Z","repository":{"id":57736348,"uuid":"139127326","full_name":"toolisticon/bean-builder","owner":"toolisticon","description":"An annotation processor to create Builder classes for POJOs (Example project for the annotation processor toolkit)","archived":false,"fork":false,"pushed_at":"2024-01-25T15:22:45.000Z","size":188,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-03-25T19:12:36.265Z","etag":null,"topics":["annotation-processor-toolkit","example"],"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/toolisticon.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-06-29T09:06:48.000Z","updated_at":"2023-12-18T07:48:15.000Z","dependencies_parsed_at":"2024-11-14T21:24:12.006Z","dependency_job_id":"1ecd54b6-b639-40e7-9c78-63befa5fbbb5","html_url":"https://github.com/toolisticon/bean-builder","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolisticon%2Fbean-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolisticon%2Fbean-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolisticon%2Fbean-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolisticon%2Fbean-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toolisticon","download_url":"https://codeload.github.com/toolisticon/bean-builder/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248493175,"owners_count":21113207,"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":["annotation-processor-toolkit","example"],"created_at":"2024-11-14T21:21:35.747Z","updated_at":"2025-04-11T23:22:16.698Z","avatar_url":"https://github.com/toolisticon.png","language":"Java","readme":"# Bean-Builder\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.beanbuilder/beanbuilder-processor/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.beanbuilder/beanbuilder-processor)\n[![Build Status](https://travis-ci.org/toolisticon/bean-builder.svg?branch=master)](https://travis-ci.org/toolisticon/bean-builder)\n[![codecov](https://codecov.io/gh/toolisticon/bean-builder/branch/master/graph/badge.svg)](https://codecov.io/gh/toolisticon/bean-builder)\n\nThis is an example project that demonstrates the usage of the [Annotation-Processor-Toolkit](https://github.com/holisticon/annotation-processor-toolkit) and the [Compile-Testing](https://github.com/toolisticon/compile-testing) libraries.\n\nIt provides an annotation processor that creates bean builder classes that allows you to create bean instances via an immutable fluent API.\n\n# Why you should use this project?\n\nDuring the implementation of unit or integration test it's a common task to setup bean instances used for testing. \n\nUsually it's more convenient and far more readable to use a fluent builder api to create the bean instances than to create a bean instance and to use it's setter methods.\n\nThis project provides an annotation processor which allows you to generate a bean builder class for your own and 3rd party bean classes. It even supports setting of inherited attributes.\n\n# Features\nAnnotation processor that\n\n- creates a bean builder class for your own and 3rd party bean classes that allows you to create bean instances via a fluent API.\n- is fully lombok compatible\n\n# How does it work?\n\n\nFirst you need to add the bean builder annotation processor api dependency to your project.\n\n```xml\n\u003cdependencies\u003e\n    \u003c!-- must be on provided scope since it is just needed at compile time --\u003e\n    \u003cdependency\u003e\n\t\u003cgroupId\u003eio.toolisticon.beanbuilder\u003c/groupId\u003e\n\t\u003cartifactId\u003ebeanbuilder-api\u003c/artifactId\u003e\n    \u003cversion\u003e${CURRENT_VERSION}\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\nThe annotation processor should be applied by defining it in annotation processor path of maven-compile-plugin:\n```xml\n\u003cplugin\u003e\n   \u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n   \u003cconfiguration combine.self=\"append\"\u003e\n       \u003cannotationProcessorPaths\u003e\n           \u003cpath\u003e\n               \u003cgroupId\u003eio.toolisticon.beanbuilder\u003c/groupId\u003e\n               \u003cartifactId\u003ebeanbuilder-processor\u003c/artifactId\u003e\n               \u003cversion\u003e${CURRENT_VERSION}\u003c/version\u003e\n           \u003c/path\u003e\n       \u003c/annotationProcessorPaths\u003e\n   \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nBean builder classes can be created by annotating your bean class with the _Builder_ annotation or by using the _ThirdPartyBeanBuilder_ annoation in a packacke-info.java file.\n\nFor further information about usage check Examples section down below.\n\n## Preconditions\n\nBuilder classes can be created for classes that \n\n- provide an accessible NoArg constructor\n- provide getters and setter for fields (explicitely implemeted or via lombok)\n\n\n## Example\n\nPOJO:\n\n```java\n@BeanBuilder\npublic class TestBean {\n\n    private String stringField;\n    private Long longField;\n    \n    public void setStringField(String stringField) {\n        this.stringField = stringField;\n    }\n    \n    public String getStringField() {\n        return this.stringField;\n    }\n    \n    public void setLongField(String longField) {\n        this.longField = longField;\n    }\n    \n    public Long getLongField() {\n        return this.longField;\n    }\n\n}\n```\n    \nPOJO with lombok:\n\n```java\n@BeanBuilder\n@Data\npublic class TestBean {\n\n    private String stringField;\n    private Long longField;\n\n}\n```\n    \nUsage of builder:\n   \n```java\nTestBean testBean = TestBeanBuilder.createBuilder()\n   .withLongField(5L)\n   .withStringField(\"TEST\")\n   .build(); \n```\n\nIt's also possible to generate bean builder classes for existing classes by using the ThirdPartyBeanBuilder annotation in a package-info.java file.\nIn this case the Builder will be created inside the annotated package with package private visibility.\n\n```java\n@ThirdPartyBeanBuilder({TestBean.class})\npackage io.toolisticon.beanbuilder.integrationtest;\n\nimport io.toolisticon.beanbuilder.api.ThirdPartyBeanBuilder;\n```\n    \n# Contributing\n\nWe welcome any kind of suggestions and pull requests.\n\n## Building and developing the Bean-Builder\n\nThe Bean-Builder is built using Maven.\nA simple import of the pom in your IDE should get you up and running. To build the bean-builder on the commandline, just run `mvn` or `mvn clean install`\n\n## Requirements\n\nThe likelihood of a pull request being used rises with the following properties:\n\n- You have used a feature branch.\n- You have included a test that demonstrates the functionality added or fixed.\n- You adhered to the [code conventions](http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html).\n\n## Contributions\n\n- (2018) Tobias Stamann (Holisticon AG)\n\n# License\n\nThis project is released under the revised [MIT License](LICENSE).\n\nThis project includes and repackages the [Annotation-Processor-Toolkit](https://github.com/holisticon/annotation-processor-toolkit) released under the  [MIT License](/3rdPartyLicenses/annotation-processor-toolkit/LICENSE.txt).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolisticon%2Fbean-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoolisticon%2Fbean-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolisticon%2Fbean-builder/lists"}