Skip to content

Commit

Permalink
Eliminate jstructural
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed May 4, 2024
1 parent d92b1ba commit 7af7d71
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 534 deletions.
52 changes: 52 additions & 0 deletions README.in
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"
```
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,56 @@ jproperties
| OpenJDK (Temurin) LTS | Linux | [![Build (OpenJDK (Temurin) LTS, Linux)](https://img.shields.io/github/actions/workflow/status/io7m-com/jproperties/main.linux.temurin.lts.yml)](https://www.github.com/io7m-com/jproperties/actions?query=workflow%3Amain.linux.temurin.lts)|
| OpenJDK (Temurin) Current | Windows | [![Build (OpenJDK (Temurin) Current, Windows)](https://img.shields.io/github/actions/workflow/status/io7m-com/jproperties/main.windows.temurin.current.yml)](https://www.github.com/io7m-com/jproperties/actions?query=workflow%3Amain.windows.temurin.current)|
| OpenJDK (Temurin) LTS | Windows | [![Build (OpenJDK (Temurin) LTS, Windows)](https://img.shields.io/github/actions/workflow/status/io7m-com/jproperties/main.windows.temurin.lts.yml)](https://www.github.com/io7m-com/jproperties/actions?query=workflow%3Amain.windows.temurin.lts)|

## 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"
```

228 changes: 0 additions & 228 deletions com.io7m.jproperties.documentation/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7af7d71

Please sign in to comment.