another solution is to pass T rather then Class<T> and return T.