implicit final class Requiring[A] extends 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 akka.util.Helpers.Requiring def addNaturals(nats: List[Int]): Int = { require(nats forall (_ >= 0), "List contains negative numbers") nats.foldLeft(0)(_ + _) } requiring(_ >= 0)
- Annotations
- @inline()
- Source
- Helpers.scala
- Alphabetic
- By Inheritance
- Requiring
- AnyVal
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
Requiring(value: A)
- value
The value to check.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
- def +(other: String): String
- def ->[B](y: B): (Requiring[A], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def ensuring(cond: (Requiring[A]) ⇒ Boolean, msg: ⇒ Any): Requiring[A]
- def ensuring(cond: (Requiring[A]) ⇒ Boolean): Requiring[A]
- def ensuring(cond: Boolean, msg: ⇒ Any): Requiring[A]
- def ensuring(cond: Boolean): Requiring[A]
- def formatted(fmtstr: String): String
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
requiring(cond: (A) ⇒ Boolean, msg: ⇒ Any): A
Check that a condition is true for the
value.Check that a condition is true for the
value. If true, returnvalue, otherwise throw anIllegalArgumentExceptionwith the given message.- cond
The function used to check the
value.- msg
The message to report if the condition isn't met.
- Annotations
- @inline()
-
def
requiring(cond: Boolean, msg: ⇒ Any): A
Check that a condition is true.
Check that a condition is true. If true, return
value, otherwise throw anIllegalArgumentExceptionwith the given message.- cond
The condition to check.
- msg
The message to report if the condition isn't met.
- Annotations
- @inline()
-
def
toString(): String
- Definition Classes
- Any
- val value: A
- def →[B](y: B): (Requiring[A], B)