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

advxml.core.Predicate.scala Maven / Gradle / Ivy

There is a newer version: 2.3.0-NEW-BUILD
Show newest version
package advxml.core

object Predicate {

  /**
    * Combine two predicates(`T => Boolean`) with `And` operator.
    *
    * @param p1 First predicate
    * @param p2 Second predicate
    * @tparam T Subject type of predicates
    * @return Result of combination of `p1` and `p2` using `And` operator.
    */
  def and[T](p1: T => Boolean, p2: T => Boolean): T => Boolean = t => p1(t) && p2(t)

  /**
    * Combine two predicates(`T => Boolean`) with `Or` operator.
    *
    * @param p1 First predicate
    * @param p2 Second predicate
    * @tparam T Subject type of predicates
    * @return Result of combination of `p1` and `p2` using `Or` operator.
    */
  def or[T](p1: T => Boolean, p2: T => Boolean): T => Boolean = t => p1(t) || p2(t)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy