Typesafe Config 및 scala의 pureconfig를 사용하여 다음 수준의 추상화를 사용하여 다음 메소드를 생성 할 수 있습니까? 구성 판독기가 follows으로 지정되어야하는 정의 된 사례 클래스가 있음을 알고 있습니다. 왜냐하면 다음은 limitations이기 때문입니다 ... 모든 유형의 사례 클래스는 ... 모든 경우에 ConfigReaders가 구현되어 있습니까?은 매개 변수 판독기에 대한 암시 적 값을 찾을 수 없습니다. pureconfig.ConfigReader [T]
/**
* @param path the.path.to.the.branch
* @param config the com.typesafe.config obj
* @tparam T - the type of the case class obj
* @return the filled-in obj of type T
*
*/
def getConfigType[T](path: String, config :Config) :Option[T] = {
val renderOpts = ConfigRenderOptions.defaults
.setOriginComments(false).setComments(false).setJson(true)
val levelConfig :Config = config.getConfig(path)
val strConfig: String = config.getConfig(path).root().render(renderOpts)
loadConfig[T](ConfigFactory.parseString(strConfig)) match {
case Right(objFilledCaseClass) => Some(objFilledCaseClass)
case Left(errors) => throw new RuntimeException(s"Invalid configuration: $errors")
}
}
}