mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-29 11:42:15 +00:00
Updated docs and changelog
This commit is contained in:
parent
439d1c600d
commit
af5a2a5867
2 changed files with 7 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
* Support for underscores in numbers (the feature branch had accidentally not been merged! :( )
|
* Support for underscores in numbers (the feature branch had accidentally not been merged! :( )
|
||||||
|
* Overloaded getters that take a default value. Thanks to __[udiabon](https://github.com/udiabon)__.
|
||||||
|
|
||||||
## 0.4.0 / 2015-02-16
|
## 0.4.0 / 2015-02-16
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,8 @@ String network3Operator2Location = toml.getString("networks[2].operators[1].loca
|
||||||
|
|
||||||
The constructor can be given a set of default values that will be used as fallbacks. For tables and table arrays, a shallow merge is performed.
|
The constructor can be given a set of default values that will be used as fallbacks. For tables and table arrays, a shallow merge is performed.
|
||||||
|
|
||||||
|
You can also call an overloaded version of the getters that take a default value. Note that the default value provided in the constructor take precedence over the one provided by the getter.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# defaults
|
# defaults
|
||||||
a = 2
|
a = 2
|
||||||
|
@ -193,10 +195,12 @@ Toml defaults = new Toml().parse(getDefaultsFile());
|
||||||
Toml toml = new Toml(defaults).parse(getTomlFile());
|
Toml toml = new Toml(defaults).parse(getTomlFile());
|
||||||
|
|
||||||
Long a = toml.getLong("a"); // returns 1, not 2
|
Long a = toml.getLong("a"); // returns 1, not 2
|
||||||
Long b = toml.getLong("b"); // returns 3
|
Long b = toml.getLong("b"); // returns 3, taken from defaults provided to constructor
|
||||||
|
Long bPrefersConstructor = toml.getLong("b", 5); // returns 3, not 5
|
||||||
Long c = toml.getLong("c"); // returns null
|
Long c = toml.getLong("c"); // returns null
|
||||||
|
Long cWithDefault = toml.getLong("c", 5); // returns 5
|
||||||
Long tableC = toml.getLong("table.c"); // returns 2, not 4
|
Long tableC = toml.getLong("table.c"); // returns 2, not 4
|
||||||
Long tableD = toml.getLong("table.d"); // returns null, not 5
|
Long tableD = toml.getLong("table.d"); // returns null, not 5, because of shallow merge
|
||||||
Long arrayD = toml.getLong("array[0].d"); // returns 3
|
Long arrayD = toml.getLong("array[0].d"); // returns 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue