com.github.tonivade.purefun.Matcher2 Maven / Gradle / Ivy
/*
* Copyright (c) 2018-2020, Antonio Gabriel Muñoz Conejo
* Distributed under the terms of the MIT License
*/
package com.github.tonivade.purefun;
@FunctionalInterface
public interface Matcher2 extends Recoverable {
default boolean match(A a, B b) {
try {
return run(a, b);
} catch (Throwable t) {
return sneakyThrow(t);
}
}
boolean run(A a, B b) throws Throwable;
default Matcher1> tupled() {
return tuple -> match(tuple.get1(), tuple.get2());
}
static Matcher2 invalid() {
return (a, b) -> { throw new IllegalStateException(); };
}
static Matcher2 otherwise() {
return (a, b) -> true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy