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

com.igormaznitsa.meta.common.interfaces.CheckedPredicate Maven / Gradle / Ivy

The newest version!
package com.igormaznitsa.meta.common.interfaces;

import static java.util.Objects.requireNonNull;

/**
 * Checked version of predicate.
 *
 * @param  type of argument
 * @since 1.2.1
 */
@FunctionalInterface
public interface CheckedPredicate {
  boolean test(T t) throws Exception;

  default CheckedPredicate and(CheckedPredicate other) throws Exception {
    requireNonNull(other);
    return (t) -> test(t) && other.test(t);
  }

  default CheckedPredicate negate() throws Exception {
    return (t) -> !test(t);
  }

  default CheckedPredicate or(CheckedPredicate other) throws Exception {
    requireNonNull(other);
    return (t) -> test(t) || other.test(t);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy