Object

ars.precondition

RequireUtils

Related Doc: package precondition

Permalink

object RequireUtils

Validation utility methods.

Since

0.0.1

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RequireUtils
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type RequireElementFunction[T] = (T, String, Int) ⇒ Unit

    Permalink

    Takes the element value, the name and the index as parameters and invokes RequireUtils#fail if requirements isn't satisfied.

  2. type RequireFunction[T] = (T, String) ⇒ Unit

    Permalink

    Takes the value and the name as parameters and invokes RequireUtils#fail if requirements isn't satisfied.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def fail(message: ⇒ Any): Unit

    Permalink

    Fails test.

    Fails test. Must be invoked at every time when requireXXX method fails. Default implementation throws an IllegalArgumentException with message built by RequireUtils#failureMessage method.

    Override this implementation if you want another failure behaviour of all requireXXX methods of this objects.

    For example if you want to throw MyApiException use this code:

    override def fail(message: => Any) = {
      throw new MyApiException(failureMessage(message))
    }
    message

    a String to include in the failure message

    Annotations
    @inline()
  9. def failureMessage(message: ⇒ Any): String

    Permalink

    Builds the failure message of any requireXXX method.

    Builds the failure message of any requireXXX method. Default implementation concatenates prefix returned by RequireUtils#prefix method followed by message followed by postfix returned by RequireUtils#postfix method.

    Override this implementation if you want to intercept or change rules of building failure messages.

    message

    the source message

    returns

    the failure message

    Annotations
    @inline()
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. def optional[T](value: Option[T])(require: (T) ⇒ Unit): Unit

    Permalink

    Invokes require function if value is Some(_) and do nothing otherwise.

    Invokes require function if value is Some(_) and do nothing otherwise.

    T

    the type of value

    value

    the value

    require

    the function

    Annotations
    @inline()
  18. def postfix: String

    Permalink

    returns

    the postfix of any requireXXX method failure message string

    Annotations
    @inline()
  19. def prefix: String

    Permalink

    returns

    the prefix of any requireXXX method failure message string

    Annotations
    @inline()
  20. def require(requirement: Boolean, message: ⇒ Any): Unit

    Permalink

    Tests an expression, invoking RequireUtils#fail if false.

    Tests an expression, invoking RequireUtils#fail if false.

    requirement

    the expression to test

    message

    a String to include in the failure message

    Annotations
    @inline()
  21. def requireAll[T](value: Iterable[T], name: String = NoNameParameter)(require: RequireElementFunction[T]): Unit

    Permalink

    Tests that all elements of iterable value satisfy the predicate, and otherwise throws IllegalArgumentException.

    Tests that all elements of iterable value satisfy the predicate, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable value

    name

    the name to include in the failure message

    require

    the function

    Annotations
    @inline()
  22. def requireAllNotBlank(value: Iterable[String], name: String = NoNameParameter): Unit

    Permalink

    Tests that iterable value does not contain blank (null or empty) strings, and otherwise throws IllegalArgumentException.

    Tests that iterable value does not contain blank (null or empty) strings, and otherwise throws IllegalArgumentException.

    value

    the iterable value

    name

    the name to include in the failure message

    Annotations
    @inline()
  23. def requireAllNotNull[T <: AnyRef](value: Iterable[T], name: String = NoNameParameter): Unit

    Permalink

    Tests that iterable value does not contain null values, and otherwise throws IllegalArgumentException.

    Tests that iterable value does not contain null values, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable value

    name

    the name to include in the failure message

    Annotations
    @inline()
  24. def requireAtLeastOneOf[T](value: Iterable[T], name: String = NoNameParameter)(seq: Iterable[T], allowDups: Boolean = false): Unit

    Permalink

    Tests that at least one of elems of seq is contained in value

    Tests that at least one of elems of seq is contained in value

    T

    the type of value

    value

    the value

    name

    the name to include in the failure message

    seq

    the sequence of values

    allowDups

    is allow duplicates

    Annotations
    @inline()
  25. def requireByte(value: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that value is a Byte number string, and otherwise throws IllegalArgumentException.

    Tests that value is a Byte number string, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  26. def requireDouble(value: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that value is a Double number string, and otherwise throws IllegalArgumentException.

    Tests that value is a Double number string, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  27. def requireEmail(email: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that string email is a correct email address.

    Tests that string email is a correct email address.

    email

    the testing email string

    name

    the name to include in the failure message

    Annotations
    @inline()
  28. def requireFloat(value: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that value is a Float number string, and otherwise throws IllegalArgumentException.

    Tests that value is a Float number string, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  29. def requireInt(value: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that value is an Int number string, and otherwise throws IllegalArgumentException.

    Tests that value is an Int number string, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  30. def requireLong(value: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that value is a Long number string, and otherwise throws IllegalArgumentException.

    Tests that value is a Long number string, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  31. def requireNegative[T](value: T, name: String = NoNameParameter)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is negative, and otherwise throws IllegalArgumentException.

    Tests that value is negative, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  32. def requireNonNegative[T](value: T, name: String = NoNameParameter)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is positive or zero, and otherwise throws IllegalArgumentException.

    Tests that value is positive or zero, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  33. def requireNonPositive[T](value: T, name: String = NoNameParameter)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is negative or zero, and otherwise throws IllegalArgumentException.

    Tests that value is negative or zero, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  34. def requireNotBlank[T](value: Iterable[T]): Unit

    Permalink

    Tests that sequence value isn't null or empty, and otherwise throws IllegalArgumentException.

    Tests that sequence value isn't null or empty, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable to test

    Annotations
    @inline()
  35. def requireNotBlank[T](value: Iterable[T], name: String): Unit

    Permalink

    Tests that sequence value isn't null or empty, and otherwise throws IllegalArgumentException.

    Tests that sequence value isn't null or empty, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  36. def requireNotBlank(value: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that value isn't null or empty (after trim), and otherwise throws IllegalArgumentException.

    Tests that value isn't null or empty (after trim), and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  37. def requireNotNull(value: AnyRef, name: String = NoNameParameter): Unit

    Permalink

    Tests that value isn't null, and otherwise throws IllegalArgumentException.

    Tests that value isn't null, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  38. def requireNumber[T](value: T, name: String = NoNameParameter)(number: T)(implicit arg0: Numeric[T]): Unit

    Permalink

    Test that value is equal to number, and otherwise throws IllegalArgumentException.

    Test that value is equal to number, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the value

    number

    the required number

    Annotations
    @inline()
  39. def requireNumberFrom[T](value: T, name: String = NoNameParameter)(leftBound: T, leftBoundType: BoundType = Inclusive)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is from leftBound with bound type leftBoundType until maximum value of type T (inclusive).

    Tests that value is from leftBound with bound type leftBoundType until maximum value of type T (inclusive).

    T

    the type of value

    value

    the value

    leftBound

    the left bound

    leftBoundType

    the left bound type

    Annotations
    @inline()
  40. def requireNumberFromExclusive[T](value: T, name: String = NoNameParameter)(leftBound: T)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is from leftBound (exclusive) until maximum value of type T (inclusive).

    Tests that value is from leftBound (exclusive) until maximum value of type T (inclusive).

    T

    the type of value

    value

    the value

    leftBound

    the left bound

    Annotations
    @inline()
  41. def requireNumberInRange[T](value: T, name: String = NoNameParameter)(leftBound: T, leftBoundType: BoundType = Inclusive)(rightBound: T, rightBoundType: BoundType = Exclusive)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is from leftBound with bound type leftBoundType until rightBound with bound type rightBoundType.

    Tests that value is from leftBound with bound type leftBoundType until rightBound with bound type rightBoundType.

    T

    the type of value

    value

    the value

    leftBound

    the left bound

    leftBoundType

    the left bound type

    rightBound

    the right bound

    rightBoundType

    the right bound type

    Annotations
    @inline()
  42. def requireNumberInterval[T](value: T, name: String = NoNameParameter)(leftBound: T, rightBound: T)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is from leftBound (exclusive) until rightBound (exclusive).

    Tests that value is from leftBound (exclusive) until rightBound (exclusive).

    T

    the type of value

    value

    the value

    leftBound

    the left bound

    rightBound

    the right bound

    Annotations
    @inline()
  43. def requireNumberSegment[T](value: T, name: String = NoNameParameter)(leftBound: T, rightBound: T)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is from leftBound (inclusive) until rightBound (inclusive).

    Tests that value is from leftBound (inclusive) until rightBound (inclusive).

    T

    the type of value

    value

    the value

    leftBound

    the left bound

    rightBound

    the right bound

    Annotations
    @inline()
  44. def requireNumberUntil[T](value: T, name: String = NoNameParameter)(rightBound: T, rightBoundType: BoundType = Exclusive)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is from minimum value of type T (inclusive) until rightBound with bound type rightBoundType.

    Tests that value is from minimum value of type T (inclusive) until rightBound with bound type rightBoundType.

    T

    the type of value

    value

    the value

    rightBound

    the right bound

    rightBoundType

    the right bound type

    Annotations
    @inline()
  45. def requireOnlyOneOf[T](value: Iterable[T], name: String = NoNameParameter)(seq: Iterable[T], allowDups: Boolean = false): Unit

    Permalink

    Tests that one and only one of elems of seq is contained in value

    Tests that one and only one of elems of seq is contained in value

    T

    the type of value

    value

    the value

    name

    the name to include in the failure message

    seq

    the sequence of values

    allowDups

    is allow duplicates

    Annotations
    @inline()
  46. def requirePattern(value: String, pattern: Regex, name: String = NoNameParameter): Unit

    Permalink

    Tests that value matches regular expression pattern, and otherwise throws IllegalArgumentException.

    Tests that value matches regular expression pattern, and otherwise throws IllegalArgumentException.

    value

    the value to test

    pattern

    the pattern to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  47. def requirePositive[T](value: T, name: String = NoNameParameter)(implicit arg0: Numeric[T]): Unit

    Permalink

    Tests that value is positive, and otherwise throws IllegalArgumentException.

    Tests that value is positive, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  48. def requireShort(value: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that value is a Short number string, and otherwise throws IllegalArgumentException.

    Tests that value is a Short number string, and otherwise throws IllegalArgumentException.

    value

    the value to test

    name

    the name to include in the failure message

    Annotations
    @inline()
  49. def requireSize[T](value: Iterable[T], size: Int, name: String = NoNameParameter): Unit

    Permalink

    Tests that size of iterable value equals expected size, and otherwise throws IllegalArgumentException.

    Tests that size of iterable value equals expected size, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable value

    size

    the expected size

    name

    the name to include in the failure message

    Annotations
    @inline()
  50. def requireSizeFrom[T](value: Iterable[T], from: Int, name: String = NoNameParameter): Unit

    Permalink

    Tests that size of iterable value is from from inclusive until Int.MaxValue, and otherwise throws IllegalArgumentException.

    Tests that size of iterable value is from from inclusive until Int.MaxValue, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable value

    from

    the minimum size value (inclusive)

    name

    the name to include in the failure message

    Annotations
    @inline()
  51. def requireSizeInRange[T](value: Iterable[T], from: Int, until: Int, name: String = NoNameParameter): Unit

    Permalink

    Tests that size of iterable value is from from inclusive until until exclusive, and otherwise throws IllegalArgumentException.

    Tests that size of iterable value is from from inclusive until until exclusive, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable value

    from

    the minimum size value (inclusive)

    until

    the maximum size value (exclusive)

    name

    the name to include in the failure message

    Annotations
    @inline()
  52. def requireSizeUntil[T](value: Iterable[T], until: Int, name: String = NoNameParameter): Unit

    Permalink

    Tests that size of iterable value is from 0 inclusive until until exclusive, and otherwise throws IllegalArgumentException.

    Tests that size of iterable value is from 0 inclusive until until exclusive, and otherwise throws IllegalArgumentException.

    T

    the type of iterable elements

    value

    the iterable value

    until

    the maximum size value (exclusive)

    name

    the name to include in the failure message

    Annotations
    @inline()
  53. def requireUuid(uuid: String, name: String = NoNameParameter): Unit

    Permalink

    Tests that string uuid is a correct universally unique identifier (UUID).

    Tests that string uuid is a correct universally unique identifier (UUID).

    uuid

    the testing uuid string

    name

    the name to include in the failure message

    Annotations
    @inline()
  54. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  55. def toRequireElementFunction[T](f: RequireFunction[T]): RequireElementFunction[T]

    Permalink

    Translates RequireFunction (for example RequireUtils.requireNotBlank(value:String* or RequireUtils#requireNotNull) to RequireElementFunction to use with RequireUtils#requireAll method.

    Translates RequireFunction (for example RequireUtils.requireNotBlank(value:String* or RequireUtils#requireNotNull) to RequireElementFunction to use with RequireUtils#requireAll method.

    Default implementation concatenates name and index in string name(index).

    T

    the type of iterable elements

    f

    the function to translate

    returns

    the translated function

    Annotations
    @inline()
  56. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  57. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  59. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped