In Scala, I am doing some Java interop. I am creating a value of class Sample.Individual
and I am calling a static Java method like Sample.Individual.newBuilder()
. I am using a few classes that all have this same static method (eg: Sample.Position
and Sample.Feature
). I want to make a function that parameterizes over them, so something like:
def p[T](s: String): T = {
val pb = T.newBuilder() // this returns a value of type T.Builder
... do stuff with pb ...
pb.build() // this returns a value of type T
}
but this tells me "not found: value T"
What is the right way to parameterize the type Sample.Individual
that lets me also call static methods contained in it from Scala?