I am trying to use the Deequ library from Java, and am having issue using the following method:
def hasCompleteness(
column: String,
assertion: Double => Boolean,
hint: Option[String] = None)
: CheckWithLastConstraintFilterable = {
addFilterableConstraint { filter => completenessConstraint(column, assertion, filter, hint) }
}
In particular, for the assertion, I need to pass in a Function1<Double, Boolean>
So I use the following code to create an assertion function in Java:
public static Function1<Double, Boolean> atLeast(double thresholdPercentage) {
return new scala.compat.java8.functionConverterImpls.FromJavaFunction<>((Double actualPercentage) -> actualPercentage >= thresholdPercentage);
}
Simple enough, right?
Only, my Java Class now won't compile because the signature of the hasCompleteness method, when viewed from Java is that the assertion parameter is a Function1<Object, Object>. Thus I see the following error:
Required type: Function1<Object, Object>
Provided: Function1<Double, Boolean>
If I change my atLeast method to return an unparametrized Function1 the issue goes away, but this feels like an ugly kludge.
Am I condemned to losing the type params when using this method from Java? Or is there something perhaps wrong with my IntelliJ / Gradle setup causing this weird behavior?