i know java Constructor convert into Scala code. but this is my project Generic class implementation. i am using hibernate ,spring in this project and i create genericDAO trait but can't create It's implementation or i can't convert this java constructor to scala
This are 2 variables
private Class<T> entityClass;
private String entityClassName;
This is GenericDAOImpl class code here GenericDAOImpl is the constructor
@SuppressWarnings("unchecked")
public GenericDAOImpl() {
Type genericSuperclass;
Class<?> parametrizedClass = getClass();
do {
genericSuperclass = parametrizedClass.getGenericSuperclass();
if (genericSuperclass instanceof Class) {
parametrizedClass = (Class<?>) genericSuperclass;
}
} while (genericSuperclass != null
&& !(genericSuperclass instanceof ParameterizedType));
this.entityClass = (Class<T>) ((ParameterizedType) genericSuperclass)
.getActualTypeArguments()[0];
if (entityClass != null) {
entityClassName = entityClass.getSimpleName();
}
}
Thanks From Milano
EDIT
I tried this
@SuppressWarnings("unchecked")
def this(T,ID){
var genericSuperclass:Type;
var parametrizedClass:Class[?]=getClass
do {
genericSuperclass = parametrizedClass.getGenericSuperclass()
if (genericSuperclass instanceof[Class]) {
parametrizedClass = (Class<?>) genericSuperclass
}
} while (genericSuperclass != null
&& !(genericSuperclass instanceof [ParameterizedType]))
this.entityClass = (Class[T]) ((ParameterizedType) genericSuperclass)
.getActualTypeArguments()[0]
if (entityClass != null) {
entityClassName = entityClass.getSimpleName()
}
}
And this got compilation Error