org.apache.spark.dataflint.saas.JavaEnumNameSerializer.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spark_2.13 Show documentation
Show all versions of spark_2.13 Show documentation
Open Source Data-Application Performance Monitoring for Apache Spark
The newest version!
package org.apache.spark.dataflint.saas
import org.json4s.CustomSerializer
import org.json4s.JsonAST.JString
// copied from json4s source code, because some spark version depends on json4s versions without this class
class JavaEnumNameSerializer[E <: Enum[E]](implicit
ct: Manifest[E]
) extends CustomSerializer[E](_ =>
( {
case JString(name) =>
Enum.valueOf(ct.runtimeClass.asInstanceOf[Class[E]], name)
}, {
case dt: E =>
JString(dt.name())
}
)
)