Package org.apache.pekko.util
Class Helpers.Requiring<A>
java.lang.Object
scala.AnyVal
org.apache.pekko.util.Helpers.Requiring<A>
- Enclosing class:
- Helpers
public static final class Helpers.Requiring<A>
extends scala.AnyVal
Implicit class providing
requiring methods. This class is based on
Predef.ensuring in the Scala standard library. The difference is that
this class's methods throw IllegalArgumentExceptions rather than
AssertionErrors.
An example adapted from Predef's documentation:
import org.apache.pekko.util.Helpers.Requiring
def addNaturals(nats: List[Int]): Int = {
require(nats forall (_ >= 0), "List contains negative numbers")
nats.foldLeft(0)(_ + _)
} requiring(_ >= 0)
param: value The value to check.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Requiring
-
-
Method Details
-
value
-
requiring
Check that a condition is true. If true, returnvalue, otherwise throw anIllegalArgumentExceptionwith the given message.- Parameters:
cond- The condition to check.msg- The message to report if the condition isn't met.
-
requiring
Check that a condition is true for thevalue. If true, returnvalue, otherwise throw anIllegalArgumentExceptionwith the given message.- Parameters:
cond- The function used to check thevalue.msg- The message to report if the condition isn't met.
-
hashCode
public int hashCode() -
equals
-