diff options
author | Roman Gräf <romangraef@gmail.com> | 2020-04-30 03:28:48 +0200 |
---|---|---|
committer | Roman Gräf <romangraef@gmail.com> | 2020-04-30 03:28:48 +0200 |
commit | a22fd2a6b3248d8b9309d3a88ccc7e107d0cfcd8 (patch) | |
tree | 9a93ab31f0fee1c242bd1565dcb1c8823948622a /README.md | |
download | jrconfig-a22fd2a6b3248d8b9309d3a88ccc7e107d0cfcd8.tar.gz jrconfig-a22fd2a6b3248d8b9309d3a88ccc7e107d0cfcd8.tar.bz2 jrconfig-a22fd2a6b3248d8b9309d3a88ccc7e107d0cfcd8.zip |
Initial commitv0.1
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..df213cb --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +## romangraefs Java Config library. +I intend to mostly use this library for personal projects, so documentation might be lacking in parts. If you have questions, feel free to hit me up on [Twitter](https://twitter.com/romangraef89). That being said: + +## Usage +Java: +```java +public class ConfigurableClass1 { + public ConfigVariable<String> someConfigProp = Config.getString("someProp"); // Define a config property + + public ConfigurableClass1() { + Config.use(FilePropertiesProvider.create("config.properties")); // Define a config source. + } + + public void someMethod() { + System.out.println(someConfigProp.get()); // Load data from the config. + someConfigProp.set("New value"); + } +} +``` + +Kotlin: +```kotlin +val someConfigProp = Config.get<String>("someProp") + +fun main() { + Config.use(FilePropertiesProvider.create("config.properties")) + println(someConfigProp.get()) +} +``` + +### Api breakdown + +The API is split up into 3 parts: + + - Config variables. + +These are what you interact with, for most of your code. You obtain an instance by either calling +`Config.get(someClazz, "propName")` or you can use `Config.get<SomeClass>("propName")` in Kotlin. +Some Common Types like `String` have shortcut methods like `Config.getString("propName")`. + + - Variable Transformers. + +These parse / serialize a string value obtained from a config source. There are some default implementations +for some types (`String` and `Integer` as of right now), but you can manually create transformers +by extending `TransformerConfigVariable<T>`. + + - Config providers. + +You usually install one config provider at the very start of your main using `Config.use(provider)`. Currently there +is only one Provider, which is the `FilePropertiesProvider` which directly utilizes standard java properties. If +you want to create your own provider, you can implement `ConfigProvider` + +## Installation + +Gradle via [Jitpack](https://jitpack.io/): +```groovy +repositories { + maven { url "https://jitpack.io" } +} + +dependencies { + implementation("com.github.romangraef", "jrconfig", "v1.0") +} +``` +The version can be either a git shortref, or a [tag](https://github.com/romangraef/jrconfig/tags). + +Alternatively, a uberjar/fatjar/ shadow/shadedjar can be obtained from the [releases](https://github.com/romangraef/jrconfig/releases).
\ No newline at end of file |