06 Sep 2010
abstract class One[T,R<:Object] extends Function1[T,R] with XPathFunction { def evaluate(list:java.util.List[_]) = apply(list.get(0).asInstanceOf[T]) }
object OneString extends One[String,String]{ def apply(s:String)=s }
scala> OneString.evaluate(Collections.singletonList("ddd")) res22: String = ddd scala> val xf:XPathFunction = OneString xf: javax.xml.xpath.XPathFunction = scala> xf.evaluate(Collections.singletonList("ddd")) res24: java.lang.Object = ddd