Forwardporting the adding of throws clauses on the Java API for Function, Procedure etc

This commit is contained in:
Viktor Klang 2012-08-09 17:26:39 +02:00
parent 5b14997680
commit 231cff0613

View file

@ -14,6 +14,7 @@ import scala.util.control.NoStackTrace
* A Function interface. Used to create first-class-functions is Java.
*/
trait Function[T, R] {
@throws(classOf[Exception])
def apply(param: T): R
}
@ -21,6 +22,7 @@ trait Function[T, R] {
* A Function interface. Used to create 2-arg first-class-functions is Java.
*/
trait Function2[T1, T2, R] {
@throws(classOf[Exception])
def apply(arg1: T1, arg2: T2): R
}
@ -28,6 +30,7 @@ trait Function2[T1, T2, R] {
* A Procedure is like a Function, but it doesn't produce a return value.
*/
trait Procedure[T] {
@throws(classOf[Exception])
def apply(param: T): Unit
}
@ -35,6 +38,7 @@ trait Procedure[T] {
* An executable piece of code that takes no parameters and doesn't return any value.
*/
trait Effect {
@throws(classOf[Exception])
def apply(): Unit
}
@ -45,6 +49,7 @@ trait Creator[T] {
/**
* This method must return a different instance upon every call.
*/
@throws(classOf[Exception])
def create(): T
}
@ -93,6 +98,7 @@ object PurePartialFunction {
abstract class PurePartialFunction[A, B] extends scala.runtime.AbstractFunction1[A, B] with PartialFunction[A, B] {
import PurePartialFunction._
@throws(classOf[Exception])
def apply(x: A, isCheck: Boolean): B
final def isDefinedAt(x: A): Boolean = try { apply(x, true); true } catch { case NoMatch false }