Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
/ matcha Public archive

Fluent, Scala-like pattern matching in pure Java using Java 8's functional additions.

License

Notifications You must be signed in to change notification settings

dhsavell/matcha

Repository files navigation

Matcha

matcha

Build Status Coverage Status Maintainability

Fluent pattern matching for Java.

Matcha is an library providing a pattern-matching system for Java. It primarily focuses on being fluent, concise, and extendable.

Example

public class NumberDescriber {
    public static String describeNumber(Number number) {
        return when(number).matchedTo(String.class)
                .is(Double.class).then(i -> i + " is a double.")
                .matches(n -> (n.intValue() & 1) != 0).then(i -> i + " is odd.")
                .matches(42).then("42 is an interesting number.")
                .otherwise(n -> "I don't have much to say about " + n + ".");
    }
}

See also

Here are some other interesting projects that also implement pattern matching in Java:

About

Fluent, Scala-like pattern matching in pure Java using Java 8's functional additions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages