Packages

c

akka.util.Helpers

Requiring

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
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Requiring
  2. AnyVal
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Requiring(value: A)

    value

    The value to check.

Value Members

  1. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  2. 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, return value, otherwise throw an IllegalArgumentException with the given message.

    cond

    The function used to check the value.

    msg

    The message to report if the condition isn't met.

    Annotations
    @inline()
  3. 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 an IllegalArgumentException with the given message.

    cond

    The condition to check.

    msg

    The message to report if the condition isn't met.

    Annotations
    @inline()
  4. val value: A