I can see some problems with the Java to Scala conversion. Specifically I would replace Java's instanceof
with
isInstanceOf[SomeClass]
Casts change from
(Class[T])
to
.asInstanceOf[Class[T]]
Add the class bound ?
changes to _
(I think)
Array indexes change from square brackets to round brackets e.g.
.getActualTypeArguments[0]
to
.getActualTypeArguments(0)
Applying these changes to the original Java I get
class GenericDAOImpl[T] {
var genericSuperclass: Type = null
var parametrizedClass: Class[_] = getClass()
do {
genericSuperclass = parametrizedClass.getGenericSuperclass()
if (genericSuperclass.isInstanceOf[Class])
parametrizedClass = genericSuperclass.asInstanceOf[Class[_]]
} while (genericSuperclass != null
&& !(genericSuperclass.isInstanceOf[ParameterizedType]))
val entityClass = genericSuperclass.asInstanceOf[ParameterizedType]
.getActualTypeArguments()(0).asInstanceOf[Class[T]]
val entityClassName =
if (entityClass != null)
entityClass.getSimpleName()
else
null
but ... it doesn't make sense to me, I would need to see more of your original class to get it to work.