def apply()

in storehaus-mysql/src/main/scala/com/twitter/storehaus/mysql/ValueMapper.scala [93:108]


  def apply(v: Any): MySqlValue = v match {
    case v: Value => new MySqlValue(v)
    case v: String =>
      new MySqlValue(RawValue(Type.String, Charset.Utf8_general_ci, isBinary = false, v.getBytes))
    case v: Int => new MySqlValue(IntValue(v))
    case v: Long => new MySqlValue(LongValue(v))
    case v: Short => new MySqlValue(ShortValue(v))
    case v: ChannelBuffer =>
      val bytes = Array.ofDim[Byte](v.readableBytes)
      v.markReaderIndex()
      v.readBytes(bytes)
      v.resetReaderIndex()
      new MySqlValue(RawValue(Type.Blob, Charset.Binary, isBinary = true, bytes))
    case other => throw new UnsupportedOperationException(
      s"${v.getClass.getName} with value $other is currently not supported.")
  }