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

generated.DynSchemaArity.scala Maven / Gradle / Ivy

There is a newer version: 0.12.16
Show newest version
/*
 *  Copyright 2021 Disney Streaming
 *
 *  Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     https://disneystreaming.github.io/TOST-1.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package schematic
package scalacheck

trait DynSchemaArity[S[x[_]] <: SchemaGenerator.DefaultMetamodel[x]] { self : SchemaGenerator[S] =>
  private object syntax extends struct.ClosedSyntax[S]
  import syntax._

  def dynStruct(fields : Vector[DynFieldSchema]) : DynSchema = (fields match {
    case v if v.size == 1 => struct(v(0))((a0) => dynStruct(v(0).label -> a0))
    case v if v.size == 2 => struct(v(0), v(1))((a0, a1) => dynStruct(v(0).label -> a0, v(1).label -> a1))
    case v if v.size == 3 => struct(v(0), v(1), v(2))((a0, a1, a2) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2))
    case v if v.size == 4 => struct(v(0), v(1), v(2), v(3))((a0, a1, a2, a3) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3))
    case v if v.size == 5 => struct(v(0), v(1), v(2), v(3), v(4))((a0, a1, a2, a3, a4) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4))
    case v if v.size == 6 => struct(v(0), v(1), v(2), v(3), v(4), v(5))((a0, a1, a2, a3, a4, a5) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5))
    case v if v.size == 7 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6))((a0, a1, a2, a3, a4, a5, a6) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6))
    case v if v.size == 8 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7))((a0, a1, a2, a3, a4, a5, a6, a7) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7))
    case v if v.size == 9 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8))((a0, a1, a2, a3, a4, a5, a6, a7, a8) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8))
    case v if v.size == 10 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9))
    case v if v.size == 11 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10))
    case v if v.size == 12 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11))
    case v if v.size == 13 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12))
    case v if v.size == 14 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13))
    case v if v.size == 15 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14))
    case v if v.size == 16 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14), v(15))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14, v(15).label -> a15))
    case v if v.size == 17 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14), v(15), v(16))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14, v(15).label -> a15, v(16).label -> a16))
    case v if v.size == 18 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14), v(15), v(16), v(17))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14, v(15).label -> a15, v(16).label -> a16, v(17).label -> a17))
    case v if v.size == 19 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14), v(15), v(16), v(17), v(18))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14, v(15).label -> a15, v(16).label -> a16, v(17).label -> a17, v(18).label -> a18))
    case v if v.size == 20 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14), v(15), v(16), v(17), v(18), v(19))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14, v(15).label -> a15, v(16).label -> a16, v(17).label -> a17, v(18).label -> a18, v(19).label -> a19))
    case v if v.size == 21 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14), v(15), v(16), v(17), v(18), v(19), v(20))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14, v(15).label -> a15, v(16).label -> a16, v(17).label -> a17, v(18).label -> a18, v(19).label -> a19, v(20).label -> a20))
    case v if v.size == 22 => struct(v(0), v(1), v(2), v(3), v(4), v(5), v(6), v(7), v(8), v(9), v(10), v(11), v(12), v(13), v(14), v(15), v(16), v(17), v(18), v(19), v(20), v(21))((a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) => dynStruct(v(0).label -> a0, v(1).label -> a1, v(2).label -> a2, v(3).label -> a3, v(4).label -> a4, v(5).label -> a5, v(6).label -> a6, v(7).label -> a7, v(8).label -> a8, v(9).label -> a9, v(10).label -> a10, v(11).label -> a11, v(12).label -> a12, v(13).label -> a13, v(14).label -> a14, v(15).label -> a15, v(16).label -> a16, v(17).label -> a17, v(18).label -> a18, v(19).label -> a19, v(20).label -> a20, v(21).label -> a21))
    case _ => struct(fields.toVector){ values =>  dynStruct(fields.map(_.label).zip(values):_*) }.asInstanceOf[DynSchema]
  }).asInstanceOf[DynSchema]
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy