
io.inbot.utils.PatternEvaluator Maven / Gradle / Ivy
package io.inbot.utils;
import java.util.Optional;
import java.util.function.Function;
/**
* Simple Java lambda based implementation of Kotlin and Scala style pattern matching. This provides a nice alternative to the if else chaos that and a more
* powerful alternative to switch statements. It's not perfect of course but it should allow for some limited verbosity when doing this kind of stuff.
*
* Inspired by https://kerflyn.wordpress.com/2012/05/09/towards-pattern-matching-in-java/.
*
* Because the evaluate returns an Optional, you can emulate the otherwise bit with a simple call to orElse(...).
*
* @param Input
* @param
© 2015 - 2025 Weber Informatics LLC | Privacy Policy