I plan on creating a user config file that I will later parse in order to run some checks from Amazon Deequ. I want to be able to pass the string names from the config file to get the methods; however, in my attempts to do so, I keep hitting roadblocks.
import com.amazon.deequ.checks._
val ru = scala.reflect.runtime.universe
val rm = ru.runtimeMirror(getClass.getClassLoader)
val myClass = new Check(CheckLevel.Error, "unit testing my data")
val im = rm.reflect(myClass)
val methodSymbolNonNeg = ru.typeOf[Check].decl(ru.TermName("isNonNegative")).asMethod
val methodNonNeg = im.reflectMethod(methodSymbolNonNeg)
Name: Compile Error
Message: <console>:48: error: type mismatch;
found : ru.MethodSymbol
required: ru.MethodSymbol
val methodNonNeg = im.reflectMethod(methodSymbolNonNeg)
I have tried a couple of examples from the documentation as well what I have found on here on SO. I have also checked the method names in the class myClass.getClass.getMethods.map(_.getName).foreach{println}
as well as on Github.
Additionally, I have tried using .getClass.getMethod
and invoking the method as well
val m = myClass.getClass.getMethod("isNonNegative", "".getClass, 2.13.getClass, Option("").getClass)
Name: java.lang.NoSuchMethodException
Message: com.amazon.deequ.checks.Check.isNonNegative(java.lang.String, double, scala.Some)
StackTrace: at java.lang.Class.getMethod(Class.java:1786)
Aucun commentaire:
Enregistrer un commentaire