
com.kyleu.projectile.models.thrift.schema.ThriftStructField.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of projectile-parser-thrift_2.13 Show documentation
Show all versions of projectile-parser-thrift_2.13 Show documentation
Reads and transforms Thrift IDL files
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