我有一个案例类:
case class AnomalyCheckConfigBuilder[S <: State[S]](anomalyDetectionStrategy: AnomalyDetectionStrategy,
analyzer: Analyzer[S, Metric[Double]],
anomalyCheckConfig: Option[AnomalyCheckConfig] = None)
我有一个函数,它以 Seq 的形式返回上述案例类对象的集合。
val anomalyCheckConfig : Seq[AnomalyCheckConfigBuilder[_]] = jobConfig.validate.get.getAnomalyCheckConfigBuilder
我将上面列表中的对象添加到另一个签名如下的方法中:
def addAnomalyCheck[S <: State[S]](
anomalyDetectionStrategy: AnomalyDetectionStrategy,
analyzer: Analyzer[S, Metric[Double]],
anomalyCheckConfig: Option[AnomalyCheckConfig] = None)
: this.type
我正在执行以下操作:
anomalyCheckConfig.foreach(x=>{
verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
})
我在上面的代码中遇到的错误是:
error: inferred type arguments [_$1] do not conform to method addAnomalyCheck's type parameter bounds [S <: com.amazon.deequ.analyzers.State[S]]
[ERROR] verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
error: type mismatch;
[ERROR] found : com.amazon.deequ.analyzers.Analyzer[_$1,com.amazon.deequ.metrics.Metric[Double]]
[ERROR] required: com.amazon.deequ.analyzers.Analyzer[S,com.amazon.deequ.metrics.Metric[Double]]
[ERROR] verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
代码在编译时失败,scala 无法理解状态,我无法理解_$1
来自哪里。希望对此有一些意见