Package akka.util
Class Helpers.Requiring<A>
- java.lang.Object
-
- scala.AnyVal
-
- akka.util.Helpers.Requiring<A>
-
- Enclosing class:
- Helpers
public static final class Helpers.Requiring<A> extends scala.AnyValImplicit class providingrequiringmethods. This class is based onPredef.ensuringin the Scala standard library. The difference is that this class's methods throwIllegalArgumentExceptions rather thanAssertionErrors.An example adapted from
Predef's documentation:import akka.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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object x$1)inthashCode()Arequiring(boolean cond, scala.Function0<java.lang.Object> msg)Check that a condition is true.Arequiring(scala.Function1<A,java.lang.Object> cond, scala.Function0<java.lang.Object> msg)Check that a condition is true for thevalue.Avalue()
-
-
-
Constructor Detail
-
Requiring
public Requiring(A value)
-
-
Method Detail
-
value
public A value()
-
requiring
public A requiring(boolean cond, scala.Function0<java.lang.Object> msg)
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
public A requiring(scala.Function1<A,java.lang.Object> cond, scala.Function0<java.lang.Object> msg)
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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object x$1)
- Overrides:
equalsin classjava.lang.Object
-
-