-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Affects: io7m-com/.github#2
- Loading branch information
Showing
12 changed files
with
112 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
## jproperties | ||
|
||
Java functions to access values from `java.util.Properties` collections | ||
with | ||
|
||
## Features | ||
|
||
* Functions to access `java.util.Properties` values as typed values. | ||
* High coverage test suite. | ||
* [OSGi-ready](https://www.osgi.org/) | ||
* [JPMS-ready](https://en.wikipedia.org/wiki/Java_Platform_Module_System) | ||
* ISC license. | ||
|
||
## Usage | ||
|
||
The `JProperties` class contains numerous functions to extract typed values | ||
from a `Properties` collection: | ||
|
||
``` | ||
final var p = new Properties(); | ||
p.setProperty("int0", "23"); | ||
p.setProperty("b0", "true"); | ||
|
||
JProperties.getBoolean(p, "b0"); // ⇒ true | ||
JProperties.getBigInteger(p, "int0"); // ⇒ new BigInteger(23) | ||
``` | ||
|
||
If a property is not present, or has a value that cannot be parsed as a value | ||
of the requested type, a `JPropertyException` is raised. | ||
|
||
``` | ||
JProperties.getBigInteger(p, "nonexistent") // ⇒ JPropertyNonexistent | ||
JProperties.getBigInteger(p, "b0"); // ⇒ JPropertyIncorrectType | ||
``` | ||
|
||
Functions typically have an optional variant that returns an `Optional.empty()` | ||
value on missing keys (but an exception will still be raised on type errors). | ||
|
||
``` | ||
JProperties.getStringOptional(p, "nonexistent") // ⇒ Optional.empty() | ||
JProperties.getStringOptional(p, "b0"); // ⇒ "true" | ||
``` | ||
|
||
Functions typically also have a `default` variant that can return a given | ||
default value if a property is not present (but an exception will still be | ||
raised on type errors). | ||
|
||
``` | ||
JProperties.getStringWithDefault(p, "nonexistent", "z") // ⇒ "z" | ||
JProperties.getStringWithDefault(p, "b0", "z"); // ⇒ "true" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
com.io7m.jproperties.documentation/src/main/assembly/documentation.xml
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
...perties.documentation/src/main/java/com/io7m/jproperties/documentation/Documentation.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.