<commit_before>@(generator: com.linkedin.sleipnir.generator.types.ComplexMapTypeGenerator)

@import _root_.scala.collection.JavaConverters._
@import _root_.com.linkedin.data.schema.RecordDataSchema.Field
@import _root_.com.linkedin.data.schema.EnumDataSchema

package @(generator.name.packageName)

import com.linkedin.data.DataMap
import com.linkedin.data.schema.MapDataSchema
import com.linkedin.data.template.{DataTemplate,DataTemplateUtil}
import com.linkedin.sleipnir.data.ScalaMapTemplate

import @(generator.name.shortClassName)._

class @(generator.name.shortClassName)(val map: Map[String,@(generator.valuesClassName)], mapData: DataMap) extends ScalaMapTemplate(mapData, Schema) {

  def this(map: Map[String,@(generator.valuesClassName)]) = this(map, ScalaMapTemplate.unwrapAll(map, PegasusCoercer))

  def this(data: DataMap) = this(ScalaMapTemplate.wrapAll(data, Coercer), data)

}

object @(generator.name.shortClassName) {

  private val SchemaJson: String = "@(generator.schemaJson)"

  private val Schema: MapDataSchema = DataTemplateUtil.parseSchema(SchemaJson).asInstanceOf[MapDataSchema]

  private val Coercer: PartialFunction[Any, @(generator.valuesClassName)] = {
    @(generator.valuesGenerator.schema.getDereferencedDataSchema) match {
      case _: EnumDataSchema => {
        case enum: String => @(generator.valuesGenerator.name.fullClassName).withName(enum)
      }

      case _ => {
        case data: DataMap => new @(generator.valuesClassName)(data)
      }

    }

  }

  private val PegasusCoercer: PartialFunction[@(generator.valuesClassName), AnyRef] = {
    @(generator.valuesGenerator.schema.getDereferencedDataSchema) match {
      case _: EnumDataSchema => {
        case enum: @(generator.valuesClassName) => enum.toString
      }

      case _ => {
        case dataTemplate: @(generator.valuesClassName) => dataTemplate.data()
      }

    }

  }

  def apply(map: Map[String,@(generator.valuesClassName)]) = new @(generator.name.shortClassName)(map)

}<commit_msg>Clean up naming of coercer.<commit_after>@(generator: com.linkedin.sleipnir.generator.types.ComplexMapTypeGenerator)

@import _root_.scala.collection.JavaConverters._
@import _root_.com.linkedin.data.schema.RecordDataSchema.Field
@import _root_.com.linkedin.data.schema.EnumDataSchema

package @(generator.name.packageName)

import com.linkedin.data.DataMap
import com.linkedin.data.schema.MapDataSchema
import com.linkedin.data.template.{DataTemplate,DataTemplateUtil}
import com.linkedin.sleipnir.data.ScalaMapTemplate

import @(generator.name.shortClassName)._

class @(generator.name.shortClassName)(val map: Map[String,@(generator.valuesClassName)], mapData: DataMap) extends ScalaMapTemplate(mapData, Schema) {

  def this(map: Map[String,@(generator.valuesClassName)]) = this(map, ScalaMapTemplate.unwrapAll(map, OutputCoercer))

  def this(data: DataMap) = this(ScalaMapTemplate.wrapAll(data, InputCoercer), data)

}

object @(generator.name.shortClassName) {

  private val SchemaJson: String = "@(generator.schemaJson)"

  private val Schema: MapDataSchema = DataTemplateUtil.parseSchema(SchemaJson).asInstanceOf[MapDataSchema]

  private val InputCoercer: PartialFunction[Any, @(generator.valuesClassName)] = {
    @(generator.valuesGenerator.schema.getDereferencedDataSchema) match {
      case _: EnumDataSchema => {
        case enum: String => @(generator.valuesGenerator.name.fullClassName).withName(enum)
      }

      case _ => {
        case data: DataMap => new @(generator.valuesClassName)(data)
      }

    }

  }

  private val OutputCoercer: PartialFunction[@(generator.valuesClassName), AnyRef] = {
    @(generator.valuesGenerator.schema.getDereferencedDataSchema) match {
      case _: EnumDataSchema => {
        case enum: @(generator.valuesClassName) => enum.toString
      }

      case _ => {
        case dataTemplate: @(generator.valuesClassName) => dataTemplate.data()
      }

    }

  }

  def apply(map: Map[String,@(generator.valuesClassName)]) = new @(generator.name.shortClassName)(map)

}
{'fraction_non_alphanumeric': 0.12202970297029703, 'fraction_numerical': 0.0, 'mean_word_length': 4.907894736842105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6544015', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1211, 'n_words': 194}