| JVM | Platform | Status |
|---|---|---|
| OpenJDK (Temurin) Current | Linux | |
| OpenJDK (Temurin) LTS | Linux | |
| OpenJDK (Temurin) Current | Windows | |
| OpenJDK (Temurin) LTS | Windows |
Development of this project has moved to an open-source but not open-contribution model.
Source code and commits will remain publicly available perpetually, but issues and/or pull requests will be rejected and/or ignored. Additionally, this project will now only be available via a read-only mirror at:
https://codeberg.org/io7m-com/jproperties
Java functions to access values from java.util.Properties collections in
a typed manner.
- Functions to access
java.util.Propertiesvalues as typed values. - High coverage test suite.
- OSGi-ready
- JPMS-ready
- ISC license.
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"
