I would like to know the name of a generic class.
The solution I use now is the following one. I defined the class class A[T: ClassTag] {...}
to be able to do classTag[T].toString
.
This compiles, but there is a problem with Guice. I get the error No implementation for scala.reflect.ClassTag<com.test.Person> was bound
.
Is there :
- Another solution to know the name of a generic class that could work with Guice ? or
- A way to bind
ClassTag[T]
with Guice ?
Full code :
package com.test
case class Person(age: Int)
class A[T: ClassTag] {
// I need to know the (full) name of type T (e.g. com.test.Person)
val tClassName = classTag[T].toString
}
class B @Inject()(a: A[Person]) {
}