All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.tonivade.purefun.Matcher3 Maven / Gradle / Ivy

/*
 * Copyright (c) 2018-2021, Antonio Gabriel Muñoz Conejo 
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.purefun;

@FunctionalInterface
public interface Matcher3 extends Recoverable {

  default boolean match(A a, B b, C c) {
    try {
      return run(a, b, c);
    } catch (Throwable t) {
      return sneakyThrow(t);
    }
  }

  boolean run(A a, B b, C c) throws Throwable;

  default Matcher1> tupled() {
    return tuple -> match(tuple.get1(), tuple.get2(), tuple.get3());
  }

  static  Matcher3 invalid() {
    return (a, b, c) -> { throw new IllegalStateException(); };
  }

  static  Matcher3 otherwise() {
    return (a, b, c) -> true;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy