override def from()

in scalding-core/src/main/scala/com/twitter/scalding/macros/impl/TupleFieldSetter.scala [41:58]


  override def from(
      c: Context
  )(fieldType: c.Type, idx: Int, container: c.TermName, fieldValue: c.Tree): Try[c.Tree] = Try {
    import c.universe._

    def simpleType(accessor: Tree) = q"""$accessor($idx, $fieldValue)"""

    fieldType match {
      case tpe if tpe =:= typeOf[String]  => simpleType(q"$container.setString")
      case tpe if tpe =:= typeOf[Boolean] => simpleType(q"$container.setBoolean")
      case tpe if tpe =:= typeOf[Short]   => simpleType(q"$container.setShort")
      case tpe if tpe =:= typeOf[Int]     => simpleType(q"$container.setInteger")
      case tpe if tpe =:= typeOf[Long]    => simpleType(q"$container.setLong")
      case tpe if tpe =:= typeOf[Float]   => simpleType(q"$container.setFloat")
      case tpe if tpe =:= typeOf[Double]  => simpleType(q"$container.setDouble")
      case _                              => sys.error(s"Unsupported primitive type $fieldType")
    }
  }