Object

com.nthportal.convert.Convert

Valid

Related Doc: package Convert

Permalink

object Valid extends Convert

A Convert which returns the result of a conversion as is, and throws an exception if the conversion fails.

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

Type Members

  1. type Result[T] = T

    Permalink

    A function which takes the result type of a conversion as input, and yields the return type of the conversion block.

    A function which takes the result type of a conversion as input, and yields the return type of the conversion block.

    For example, if converting a String to a Boolean, this is a function which takes Boolean as input, and yields some type Result[Boolean] (Boolean for Convert.Valid, and Option[Boolean] for Convert.Any).

    Definition Classes
    ValidConvert

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. object AutoUnwrap

    Permalink

    An object containing an implicit conversion from Result[T] to T.

    An object containing an implicit conversion from Result[T] to T. The implicit conversion allows the automatic unwrapping of Results, without explicitly calling unwrap.

    USE THIS IMPLICIT CONVERSION AT YOUR OWN RISK

    This implicit conversion can improve code readability; however, it should be used with care. As with all implicit conversions, it may be difficult to tell when it is applied by the compiler, leading to unexpected behavior which is difficult to debug.

    Additionally, because unwrap MUST be called within a conversion block, this implicit conversion MUST be called within a conversion block as well. However, if imported in the wrong scope, the compiler may insert a call to this implicit conversion outside of any conversion block. Use this implicit conversion with care.

    Definition Classes
    Convert
  5. object Implicit

    Permalink

    A wrapper object for an implicit reference to the enclosing Convert.

    A wrapper object for an implicit reference to the enclosing Convert.

    Definition Classes
    Convert
  6. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def conversion[T](res: ⇒ T): T

    Permalink

    Performs a conversion.

    Performs a conversion.

    Conversion operations MUST take place within this block (a 'conversion block').

    T

    the type of the conversion's result

    returns

    the result of the conversion, if it did not fail

    Definition Classes
    ValidConvert
    Example:
    1. conversion {
        val res = ??? // do conversion
        if (cond) fail(new IllegalArgumentException("invalid input")) // fail if something goes wrong
        res // return a result
      }
  9. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  11. def fail(ex: ⇒ Exception): Nothing

    Permalink

    Throws the specified exception.

    Throws the specified exception.

    This method MUST be called within a conversion block from this Convert instance.

    ex

    the exception to throw

    Definition Classes
    ValidConvert
  12. def finalize(): Unit

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  19. final def require(requirement: Boolean, message: ⇒ Any): Unit

    Permalink

    Tests an expression, failing the conversion if false.

    Tests an expression, failing the conversion if false. Analogous to Predef.require, except that it fails the conversion instead of always throwing an exception.

    This method MUST be called within a conversion block from this Convert instance.

    requirement

    the expression to test

    message

    a String to include in the failure message

    Definition Classes
    Convert
    Annotations
    @inline()
  20. final def require(requirement: Boolean): Unit

    Permalink

    Tests an expression, failing the conversion if false.

    Tests an expression, failing the conversion if false. Analogous to Predef.require, except that it fails the conversion instead of always throwing an exception.

    This method MUST be called within a conversion block from this Convert instance.

    requirement

    the expression to test

    Definition Classes
    Convert
    Annotations
    @inline()
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  22. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  23. def unwrap[T](result: T): T

    Permalink

    Returns the result of another conversion.

    Returns the result of another conversion.

    This method MUST be called within a conversion block from this Convert instance.

    T

    the type of the result

    result

    the result of another conversion

    returns

    the result of the other conversion

    Definition Classes
    ValidConvert
  24. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wrapException[T](matches: (Exception) ⇒ Boolean)(body: ⇒ T): T

    Permalink

    Wraps a block of code which throws an exception, failing the conversion if the block throws an exception, and the exception matches the specified predicate.

    Wraps a block of code which throws an exception, failing the conversion if the block throws an exception, and the exception matches the specified predicate.

    This method MUST be called within a conversion block from this Convert instance.

    T

    the type of the result of body

    matches

    a predicate to match certain exceptions to be wrapped

    body

    the block of code which may throw an exception

    returns

    the result of body, if it did not fail

    Definition Classes
    Convert
  28. final def wrapException[E <: Exception, T](body: ⇒ T)(implicit arg0: ClassTag[E]): T

    Permalink

    Wraps a block of code which throws an exception, failing the conversion if the block throws an exception of the specified type.

    Wraps a block of code which throws an exception, failing the conversion if the block throws an exception of the specified type.

    This method MUST be called within a conversion block from this Convert instance.

    E

    the type of the exception

    T

    the type of the result of body

    body

    the block of code which may throw an exception

    returns

    the result of body, if it did not fail

    Definition Classes
    Convert

Inherited from Convert

Inherited from AnyRef

Inherited from Any

Ungrouped