Seems the solution is possible, however a little bit tricky: for some
reason you can't import Scala Iterable type into Java code, so everything
has to be done in Scala code instead:
*def* createTapestryCoercions(configuration:
org.apache.tapestry5.ioc.Configuration[org.apache.tapestry5.ioc.services.CoercionTuple[_,
java.lang.Iterable[_]]]) = {
*val* coercion = *new* Coercion[Iterable[AnyRef],
java.lang.Iterable[_]] () {
*def* coerce(arg: Iterable[AnyRef]) = arg.asJava
}
configuration.add(*new* CoercionTuple(classOf[Iterable[AnyRef]],
classOf[java.lang.Iterable[_]], coercion))
}
On Sat, Oct 3, 2015 at 12:17 AM, Ilya Obshadko <[email protected]>
wrote:
> Just checking - did anyone ever try to create general-purpose type coercer
> for Scala types?
> It seems to be very natural solution to avoid calling .asJava on every
> return type I happen to use from Scala.
>
>
> --
> Ilya Obshadko
>
>
--
Ilya Obshadko