org.megam.util

Try

sealed abstract class Try[+R] extends AnyRef

This class represents a computation that can succeed or fail. It has two concrete implementations, Return (for success) and Throw (for failure)

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Try
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Try()

Abstract Value Members

  1. abstract def apply(): R

    Returns the value from this Return or throws the exception if this is a Throw

  2. abstract def exists(p: (R) ⇒ Boolean): Boolean

    Returns true if this Try is a Return and the predicate p returns true when applied to its value.

  3. abstract def filter(p: (R) ⇒ Boolean): Try[R]

    Converts this to a Throw if the predicate does not obtain.

  4. abstract def flatMap[R2](f: (R) ⇒ Try[R2]): Try[R2]

    Returns the given function applied to the value from this Return or returns this if this is a Throw.

    Returns the given function applied to the value from this Return or returns this if this is a Throw.

    Note The gnarly type parameterization is there for Java compatibility, since Java does not support higher-kinded types.

  5. abstract def flatten[T](implicit ev: <:<[R, Try[T]]): Try[T]

  6. abstract def handle[R2 >: R](rescueException: PartialFunction[Throwable, R2]): Try[R2]

    Calls the exceptionHandler with the exception if this is a Throw.

    Calls the exceptionHandler with the exception if this is a Throw. This is like map for the exception.

  7. abstract def isReturn: Boolean

    Returns true if the Try is a Return, false otherwise.

  8. abstract def isThrow: Boolean

    Returns true if the Try is a Throw, false otherwise.

  9. abstract def map[X](f: (R) ⇒ X): Try[X]

    Maps the given function to the value from this Return or returns this if this is a Throw

  10. abstract def onFailure(rescueException: (Throwable) ⇒ Unit): Try[R]

    Invoke the function on the error, if the computation was unsuccessful.

    Invoke the function on the error, if the computation was unsuccessful. Returns a chained this as in respond.

  11. abstract def onSuccess(f: (R) ⇒ Unit): Try[R]

    Invoked only if the computation was successful.

    Invoked only if the computation was successful. Returns a chained this as in respond.

  12. abstract def rescue[R2 >: R](rescueException: PartialFunction[Throwable, Try[R2]]): Try[R2]

    Calls the exceptionHandler with the exception if this is a Throw.

    Calls the exceptionHandler with the exception if this is a Throw. This is like flatMap for the exception.

    Note The gnarly type parameterization is there for Java compatibility, since Java does not support higher-kinded types.

  13. abstract def withFilter(p: (R) ⇒ Boolean): Try[R]

    Converts this to a Throw if the predicate does not obtain.

Concrete Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def andThen[R2](f: (R) ⇒ Try[R2]): Try[R2]

    Returns the given function applied to the value from this Return or returns this if this is a Throw.

    Returns the given function applied to the value from this Return or returns this if this is a Throw. Alias for flatMap

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def ensure(f: ⇒ Unit): Try[R]

    Invoked regardless of whether the computation completed successfully or unsuccessfully.

    Invoked regardless of whether the computation completed successfully or unsuccessfully. Implemented in terms of respond so that subclasses control evaluation order. Returns a chained this as in respond.

  10. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def foreach(f: (R) ⇒ Unit): Unit

    Applies the given function f if this is a Result.

  14. def get(): R

    Returns the value from this Return or throws the exception if this is a Throw.

    Returns the value from this Return or throws the exception if this is a Throw. Alias for apply()

  15. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  16. def getOrElse[R2 >: R](default: ⇒ R2): R2

    Returns the value from this Return or the given argument if this is a Throw.

  17. def hashCode(): Int

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

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

    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  22. def respond(k: (Try[R]) ⇒ Unit): Try[R]

    Invokes the given closure when the value is available.

    Invokes the given closure when the value is available. Returns another 'This[R]' that is guaranteed to be available only *after* 'k' has run. This enables the enforcement of invocation ordering.

  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  24. def toOption: Option[R]

    Returns None if this is a Throw or a Some containing the value if this is a Return

  25. def toString(): String

    Definition Classes
    AnyRef → Any
  26. def transform[R2](f: (Try[R]) ⇒ Try[R2]): Try[R2]

    Invokes the given transformation when the value is available, returning the transformed value.

    Invokes the given transformation when the value is available, returning the transformed value. This method is like a combination of flatMap and rescue. This method is typically used for more imperative control-flow than flatMap/rescue which often exploits the Null Object Pattern.

  27. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped