https://github.com/bzdgn/merdiven
A generic statement builder tool for all-purpose
https://github.com/bzdgn/merdiven
builder statement statementbuilder
Last synced: 10 months ago
JSON representation
A generic statement builder tool for all-purpose
- Host: GitHub
- URL: https://github.com/bzdgn/merdiven
- Owner: bzdgn
- License: apache-2.0
- Created: 2021-06-24T12:56:43.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-02T19:45:55.000Z (over 4 years ago)
- Last Synced: 2025-02-03T09:47:47.490Z (11 months ago)
- Topics: builder, statement, statementbuilder
- Language: Java
- Homepage:
- Size: 51.8 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
TOC
---
- [0 Introduction](#0-introduction)
- [1 Setup](#1-setup)
- [2 Example](#2-example)
- [3 TODO List](#3-todo-list)
- [4 Future Plan](#4-future-plan)
0 Introduction
---------------

[](https://search.maven.org/artifact/io.github.bzdgn/merdiven)
**Merdiven** is a simple generic statement builder for generic purposes. During different development projects, there was the need to have a generic statement builder that produces immutable statements thus I've created this open-source project.
[Go back to TOC](#toc)
1 Setup
--------
You can simply add **merdiven** to your project as a maven dependency;
```xml
io.github.bzdgn
merdiven
0.0.2
```
[Go back to TOC](#toc)
2 Example
----------
**Merdiven** is easy to use. A simple example to produce a statement is as follows to produce a **json** object;
```java
Statement statement = builder
.openBracket()
.openCurlyBracket()
.add("name", "Levent", ":", "\"")
.and(",")
.add("id", "717", ":", "\"")
.and(",")
.add("isOccupied", "true", ":", "\"")
.and(",")
.addParam("info", "\"")
.eq(":")
.openCurlyBracket()
.addParam("languages", "\"")
.eq(":")
.openBracket()
.addParam("english", "\"")
.and(",")
.addParam("turkish", "\"")
.and(",")
.addParam("dutch", "\"")
.closeBracket()
.closeCurlyBracket()
.closeCurlyBracket()
.closeBracket()
.build();
System.out.println(statement.toString());
```
And the output will be as follows;
```
[ { "name":"Levent" , "id":"717" , "isOccupied":"true" , "info" : { "languages" : [ "english" , "turkish" , "dutch" ] } } ]
```
Pretty printed output will be;
```json
[
{
"name": "Levent",
"id": "717",
"isOccupied": "true",
"info": {
"languages": [
"english",
"turkish",
"dutch"
]
}
}
]
```
Or to make an undefined query by your own as follows;
```java
Statement statement = builder
.add("firstName", "Levent")
.and()
.add("lastName", "Divilioglu")
.add("number", "717")
.add("github", "bzdgn")
.openBracket()
.add("type", "Engineer")
.or()
.add("type", "Guitarist")
.closeBracket()
.build();
System.out.println(statement.toString());
```
And the string output is as follows;
```
firstName="Levent" and lastName="Divilioglu" number="717" github="bzdgn" [ type="Engineer" or type="Guitarist" ]
```
[Go back to TOC](#toc)
3 TODO List
------------
- Field to list structure to be added.
- Configuration object to be implemented for generic templates
- Pretty Print functionality to be added
[Go back to TOC](#toc)
4 Future Plan
--------------
As a Camel user, I want to dig into the Camel components and want to create a camel component for **merdiven**. Also json/xml conversions may be added to the project.
[Go back to TOC](#toc)