I'm working with JAX-RS in Scala and trying to parameterise a call to:
val jc = JAXBContext.newInstance(classOf[MyClassName])
I've been using ClassManifests as per the answer here but have a couple of things I'm still struggling with. As background, my JAX-RS representations all extend a stubbed Representation class:
class Representation {}
class ExampleRepresentation extends Representation { ... }
So far I've defined my function using a ClassManifest like so:
def get[R: ClassManifest](representation: R): String = {
val jc = JAXBContext.newInstance(classManifest[R].erasure)
...
}
My first question is a bit of a silly one: how do I call this function? I can't figure out what to pass in to get() for the R type and the representation value (the accepted answer to the original question doesn't make this clear). I tried implicit typing as per paradigmatic's comment but the below generates a compile error:
get(PlatformRepresentation)
Compiling main sources...
not found: value PlatformRepresentation
My second question is: is it possible to apply an upper type bound on the R object? In other words, I know that:
R <: Representation
Is there a way of bounding this in get()'s ClassManifest type declaration?
Many thanks!