Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aesteve/vertx-pojo-config
Simple Vert.x extension to map your JsonObject configuration to a standard Java bean
https://github.com/aesteve/vertx-pojo-config
configuration json mapping validation vertx
Last synced: 5 days ago
JSON representation
Simple Vert.x extension to map your JsonObject configuration to a standard Java bean
- Host: GitHub
- URL: https://github.com/aesteve/vertx-pojo-config
- Owner: aesteve
- Created: 2016-05-01T06:44:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-01T09:55:00.000Z (over 8 years ago)
- Last Synced: 2024-10-09T08:43:37.958Z (27 days ago)
- Topics: configuration, json, mapping, validation, vertx
- Language: Java
- Homepage:
- Size: 57.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- vertx-awesome - Vert.x POJO config - Allows for mapping between standard JSON configuration and a (type-safe) configuration Java bean. Also allows the configuration bean to be validated through JSR 303. (Utilities)
README
## Vertx-pojo-config
A very simple tool to map Vert.x's json configuration onto a typed configuration Java bean.
It uses Jackson's object mapper behind the hood.
### How to use it ?
Simply make your `Verticle` extend `TypedConfigurationVerticle` and declare the class of your configuration :
```java
class SimpleConf {private String host;
private int port;public String getHost() {
return host;
}public void setHost(String host) {
this.host = host;
}public int getPort() {
return port;
}public void setPort(int port) {
this.port = port;
}
}
``````java
class SimpleConfigurationVerticle extends TypedConfigurationVerticle {@Override
public Class getConfigClass() {
return SimpleConf.class;
}
}```
Then, from within your verticle just call `getConfig()` to get the `SimpleConf` instance. The `config()` method will still be returning the `JsonObject` configuration.
### JSR 303 (Bean validation)
If an implementation of the JSR 303 (hibernate-validator for instance) within your classpath, then your configuration will be checked against a validator.
This means you can annotate your configuration with `@Email`, `@NotNull`, and stuff like that.