@@ -189,6 +189,76 @@ object Schema extends SchemaPlatformSpecific with SchemaEquality with SchemaVers
189189 case _ => schema
190190 }
191191
192+ def getTypeId [A ](schema : Schema [A ]): TypeId =
193+ schema match {
194+ case record : Record [_] => record.id
195+ case enum0 : Enum [_] => enum0.id
196+ case Primitive (standardType, _) =>
197+ val typeName = standardType.tag match {
198+ case " unit" => " scala.Unit"
199+ case " string" => " java.lang.String"
200+ case " boolean" => " scala.Boolean"
201+ case " byte" => " scala.Byte"
202+ case " short" => " scala.Short"
203+ case " int" => " scala.Int"
204+ case " long" => " scala.Long"
205+ case " float" => " scala.Float"
206+ case " double" => " scala.Double"
207+ case " binary" => " zio.Chunk"
208+ case " char" => " scala.Char"
209+ case " bigDecimal" => " java.math.BigDecimal"
210+ case " bigInteger" => " java.math.BigInteger"
211+ case " dayOfWeek" => " java.time.DayOfWeek"
212+ case " month" => " java.time.Month"
213+ case " monthDay" => " java.time.MonthDay"
214+ case " period" => " java.time.Period"
215+ case " year" => " java.time.Year"
216+ case " yearMonth" => " java.time.YearMonth"
217+ case " zoneId" => " java.time.ZoneId"
218+ case " zoneOffset" => " java.time.ZoneOffset"
219+ case " duration" => " java.time.Duration"
220+ case " instant" => " java.time.Instant"
221+ case " localDate" => " java.time.LocalDate"
222+ case " localTime" => " java.time.LocalTime"
223+ case " localDateTime" => " java.time.LocalDateTime"
224+ case " offsetTime" => " java.time.OffsetTime"
225+ case " offsetDateTime" => " java.time.OffsetDateTime"
226+ case " zonedDateTime" => " java.time.ZonedDateTime"
227+ case " uuid" => " java.util.UUID"
228+ case " currency" => " java.util.Currency"
229+ case other => other
230+ }
231+ TypeId .parse(typeName)
232+ case Transform (schema, _, _, _, _) => getTypeId(schema)
233+ case Lazy (schema0) => getTypeId(schema0())
234+ case Optional (schema, _) => TypeId .parse(" scala.Option" )
235+ case Sequence (_, _, _, _, identity) =>
236+ identity match {
237+ case s : String if s == " Chunk" => TypeId .parse(" zio.Chunk" )
238+ case s : String if s == " List" => TypeId .parse(" scala.collection.immutable.List" )
239+ case s : String if s == " Vector" => TypeId .parse(" scala.collection.immutable.Vector" )
240+ case s : String if s == " Set" => TypeId .parse(" scala.collection.immutable.Set" )
241+ case s : String if s == " NonEmptyChunk" => TypeId .parse(" zio.NonEmptyChunk" )
242+ case s : String => TypeId .parse(s)
243+ case _ => TypeId .parse(" zio.Chunk" )
244+ }
245+ case NonEmptySequence (_, _, _, _, identity) =>
246+ identity match {
247+ case s : String if s == " NonEmptyChunk" => TypeId .parse(" zio.NonEmptyChunk" )
248+ case s : String if s == " NonEmptySet" => TypeId .parse(" zio.prelude.NonEmptySet" )
249+ case s : String => TypeId .parse(s)
250+ case _ => TypeId .parse(" zio.NonEmptyChunk" )
251+ }
252+ case _ : Set [_] => TypeId .parse(" scala.collection.immutable.Set" )
253+ case _ : Map [_, _] => TypeId .parse(" scala.collection.immutable.Map" )
254+ case _ : NonEmptyMap [_, _] => TypeId .parse(" zio.prelude.NonEmptyMap" )
255+ case _ : Tuple2 [_, _] => TypeId .parse(" scala.Tuple2" )
256+ case _ : Either [_, _] => TypeId .parse(" scala.Either" )
257+ case _ : Fallback [_, _] => TypeId .parse(" zio.schema.Fallback" )
258+ case _ : Dynamic => TypeId .parse(" zio.schema.DynamicValue" )
259+ case Fail (_, _) => TypeId .Structural
260+ }
261+
192262 def record (id : TypeId , fields : Field [ListMap [String , _], _]* ): Schema [ListMap [String , _]] =
193263 GenericRecord (id, FieldSet (fields : _* ))
194264
0 commit comments