I'm developing a REST webservice in Scala using the Jersey JAX-RS reference implementation and I'm getting a strange error.
I'm trying to create a ContentDisposition object using the ContentDisposition.ContentDispositionBuilder.
ContentDisposition.ContentDispositionBuilder
has two types T extends ContentDisposition.ContentDispositionBuilder
and V extends ContentDisposition
. The method type
of ContentDisposition
returns a builder instance.
The code
val contentDisposition = ContentDisposition.`type`(MediaType.APPLICATION_OCTET_STREAM).build()
works however
val contentDisposition = ContentDisposition.`type`(MediaType.APPLICATION_OCTET_STREAM).fileName("dummy").build()
produces the compiler error
error: value build is not a member of ?0
val contentDisposition = ContentDisposition.`type`(MediaType.APPLICATION_OCTET_STREAM).fileName("dummy").build()
^
(Note that type
needs to be put in "quotation marks" because it's a keyword in Scala)
fileName
of ContentDispositionBuilder
returns an instance of T
so this should actually work.
I don't get this. Any idea? I'm using Scala 2.9.0.1 by the way.
Update:
This works. But why do I need the casting here?
val contentDisposition = ContentDisposition.`type`(MediaType.APPLICATION_OCTET_STREAM)
.fileName("dummy")
.asInstanceOf[ContentDisposition.ContentDispositionBuilder[_,_]]
.build()