I'm trying to use reflection, pretty much in the same way seen in the answer of this question. The thing is that my code looks like this:
class A {
def query1(arg: Int): String = { Some code }
def query2(arg: String): String = { Some code }
def query3(): String = { Some code }
}
object A {
def apply(query: String, arg: Any): String = {
val a = new A
val method = a.getClass.getMethod(query,arg.getClass)
method.invoke(a,arg)
}
}
But this cannot be compiled, and I get an error:
type mismatch; found: Any, required: Object
Any ideas how can I make this work?