orj
U+FB00 · LATIN SMALL LIGATURE FF

functional for Java

Four small types you'd otherwise re-implement in every project: Result, Validated, NonEmptyList, Retry. Java 21+. Zero runtime dependencies. A ligature's worth of library: two things, functional types and plain Java, set as one glyph.

PROVEN, NOT PROMISED

This example is a test. It ran, and passed, before this page was built:

Validated<String, Form> form = Validated.accumulate(acc -> {
    var name = acc.on(nonBlank("name", ""));
    var email = acc.on(nonBlank("email", "ada@analytical.engine"));
    var age = acc.on(validAge(-3));
    return new Form(name.value(), email.value(), age.value());
});

assertEquals(
        Validated.invalid(NonEmptyList.of(
                "name must not be blank",
                "age must be positive, was -3")),
        form);

Read the Validated: every error, at once guide →

GUIDES
GET IT
// Gradle
implementation("dev.fforj:fforj:0.2.0")

Or copy the source of the types you need into your project: every class stands alone by design, and behaves identically either way. The API reference is the full Javadoc.

DELIBERATELY NOT HERE

The surface area is bounded on purpose. This library will not grow into the thing it replaces.