Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Repository files navigation

jproperties

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.jproperties

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

Repository Relocation

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

jproperties

Java functions to access values from java.util.Properties collections in a typed manner.

Features

  • Functions to access java.util.Properties values as typed values.
  • High coverage test suite.
  • OSGi-ready
  • JPMS-ready
  • 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"

About

Typed property handling

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages