I am developing a REST web service in Scala using JAX-RS Jersey and I get a weird error.
I am trying to create a ContentDisposition object using ContentDisposition.ContentDispositionBuilder .
ContentDisposition.ContentDispositionBuilder has two types of T extends ContentDisposition.ContentDispositionBuilder and V extends ContentDisposition . The type of ContentDisposition returns an instance of the linker.
The code
val contentDisposition = ContentDisposition.`type`(MediaType.APPLICATION_OCTET_STREAM).build()
works however
val contentDisposition = ContentDisposition.`type`(MediaType.APPLICATION_OCTET_STREAM).fileName("dummy").build()
creates a 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 enclosed in “quotation marks” because it is a keyword in Scala)
fileName from ContentDispositionBuilder returns an instance of T , so this should work.
I do not understand. Any ideas? By the way, I am using Scala 2.9.0.1.
Update:
It works. But why do I need casting here?
val contentDisposition = ContentDisposition.`type`(MediaType.APPLICATION_OCTET_STREAM) .fileName("dummy") .asInstanceOf[ContentDisposition.ContentDispositionBuilder[_,_]] .build()
Sven jacobs
source share