https://github.com/tonivade/purecfg
Pure Functional Configuration Library
https://github.com/tonivade/purecfg
configuration experimental functional-programming java purefun
Last synced: 12 months ago
JSON representation
Pure Functional Configuration Library
- Host: GitHub
- URL: https://github.com/tonivade/purecfg
- Owner: tonivade
- License: mit
- Created: 2020-02-02T19:01:19.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-28T07:05:32.000Z (12 months ago)
- Last Synced: 2025-03-28T08:22:03.806Z (12 months ago)
- Topics: configuration, experimental, functional-programming, java, purefun
- Language: Java
- Size: 752 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PureCFG
Inspired by this [presentation](https://github.com/jdegoes/scalaworld-2015/blob/master/presentation.md)
## Objectives
- Create a pure functional library to load configuration from different sources, like properties files, json, yaml or any other source.
- Allow to switch from sources without changing the program.
- Self documented.
- Type safe.
Now it supports properties and toml files.
## Example
```toml
[server]
host = "localhost"
port = 8080
```
```java
record HostAndPort(String host, Integer port) { }
var readHostAndPort = PureCFG.map2(PureCFG.readString("host"), PureCFG.readInt("port"), HostAndPort::new);
var program = PureCFG.readConfig("server", readHostAndPort);
var config = program.unsafeRun(Source.fromToml("config.toml"));
assertEquals(new HostAndPort("localhost", 8080), config);
```
## License
Distributed under MIT License