Error while passing arguments to methods. I have an object builddeequ_rules
and calling methods using Scala reflection.
def build(rules: List[Map[String, Any]]): Check = {
for (constraint <- rules) {
val name = constraint("name")
val args = constraint("args")
val hiObj = builddeequ_rules
val mtd = hiObj.getClass.getMethod(name.toString,args.getClass)
mtd.invoke(hiObj,args)
}
import com.amazon.deequ.checks.{Check, CheckLevel}
object builddeequ_rules {
var checks = Check(CheckLevel.Warning, "Data unit test")
def isComplete(args: Any) {
val arg = args.asInstanceOf[Map[String,Any]]
val columnName = arg("column").toString
checks = checks.isComplete(columnName)
}
def isUnique(args: Any) {
val arg = args.asInstanceOf[Map[String,Any]]
val columnName = arg("column").toString
checks = checks.isUnique(columnName)
}
def isPositive(args: Any) {
val arg = args.asInstanceOf[Map[String,Any]]
val columnName = arg("column").toString
checks = checks.isPositive(columnName)
}
I am getting below error. Need help!
Error: type mismatch;
found : Any
required: Object
mtd.invoke(hiObj,args)