Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidmoten/java-builder
Generate java builder pattern from a list of variable declarations
https://github.com/davidmoten/java-builder
Last synced: about 1 month ago
JSON representation
Generate java builder pattern from a list of variable declarations
- Host: GitHub
- URL: https://github.com/davidmoten/java-builder
- Owner: davidmoten
- License: apache-2.0
- Created: 2014-02-04T05:38:31.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-12-16T10:11:01.000Z (almost 9 years ago)
- Last Synced: 2023-03-11T13:53:33.382Z (over 1 year ago)
- Language: Java
- Size: 20.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
java-builder
============Generate java builder pattern from a list of variable declarations
Do it online at https://java-builder.herokuapp.com.
Run locally
--------------
```bash
git clone https://github.com/davidmoten/java-builder.git
cd java-builder
mvn jetty:run
```Then go to [http://localhost:8080](http://localhost:8080).
Example
------------
Converts this java fragment:
```java
public class Fred {private String name;
private int count;
```
to this:
```java
private final String name;
private final int count;private Fred(String name, int count){
this.name = name;
this.count = count;
}public String getName() {
return name;
}public int getCount() {
return count;
}public static Builder builder() {
return new Builder();
}public static class Builder {
private String name;
private int count;private Builder() {
}public Builder name(String name) {
this.name = name;
return this;
}public Builder count(int count) {
this.count = count;
return this;
}public Fred build() {
return new Fred(name, count);
}
}
```
Known limitations
----------------------javadoc and annotations might confuse it as would comma separated field declarations.