All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kyleu.projectile.models.thrift.schema.ThriftStructField.scala Maven / Gradle / Ivy

The newest version!
package com.kyleu.projectile.models.thrift.schema

import com.facebook.swift.parser.model.{ConstValue, ThriftField, ThriftType}
import com.facebook.swift.parser.model.ThriftField.Requiredness

object ThriftStructField {
  private[this] val renames = Map("type" -> "`type`")

  private[this] def fromKeyTypeVal(key: String, required: Boolean, t: ThriftType, v: Option[ConstValue]) = {
    val name = renames.getOrElse(key, key)
    ThriftStructField(key, name, required, t, v)
  }

  def fromThrift(f: ThriftField) = {
    fromKeyTypeVal(key = f.getName, required = f.getRequiredness != Requiredness.OPTIONAL, t = f.getType, v = Option(f.getValue.orNull))
  }
}

case class ThriftStructField(key: String, name: String, required: Boolean, t: ThriftType, value: Option[ConstValue])




© 2015 - 2025 Weber Informatics LLC | Privacy Policy