@@ -57,6 +57,125 @@ object DynamicTuple {
57
57
case _ => TupleXXL (xs).asInstanceOf [T ]
58
58
}
59
59
60
+ def dynamicFromProduct [T <: Tuple ](xs : Product ): T = (xs.productArity match {
61
+ case 1 =>
62
+ xs match {
63
+ case xs : Tuple1 [_] => xs
64
+ case xs => Tuple1 (xs.productElement(0 ))
65
+ }
66
+ case 2 =>
67
+ xs match {
68
+ case xs : Tuple2 [_, _] => xs
69
+ case xs => Tuple2 (xs.productElement(0 ), xs.productElement(1 ))
70
+ }
71
+ case 3 =>
72
+ xs match {
73
+ case xs : Tuple3 [_, _, _] => xs
74
+ case xs => Tuple3 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ))
75
+ }
76
+ case 4 =>
77
+ xs match {
78
+ case xs : Tuple4 [_, _, _, _] => xs
79
+ case xs => Tuple4 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ))
80
+ }
81
+ case 5 =>
82
+ xs match {
83
+ case xs : Tuple5 [_, _, _, _, _] => xs
84
+ case xs => Tuple5 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ))
85
+ }
86
+ case 6 =>
87
+ xs match {
88
+ case xs : Tuple6 [_, _, _, _, _, _] => xs
89
+ case xs => Tuple6 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ))
90
+ }
91
+ case 7 =>
92
+ xs match {
93
+ case xs : Tuple7 [_, _, _, _, _, _, _] => xs
94
+ case xs => Tuple7 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ))
95
+ }
96
+ case 8 =>
97
+ xs match {
98
+ case xs : Tuple8 [_, _, _, _, _, _, _, _] => xs
99
+ case xs => Tuple8 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ))
100
+ }
101
+ case 9 =>
102
+ xs match {
103
+ case xs : Tuple9 [_, _, _, _, _, _, _, _, _] => xs
104
+ case xs => Tuple9 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ))
105
+ }
106
+ case 10 =>
107
+ xs match {
108
+ case xs : Tuple10 [_, _, _, _, _, _, _, _, _, _] => xs
109
+ case xs => Tuple10 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ))
110
+ }
111
+ case 11 =>
112
+ xs match {
113
+ case xs : Tuple11 [_, _, _, _, _, _, _, _, _, _, _] => xs
114
+ case xs => Tuple11 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ))
115
+ }
116
+ case 12 =>
117
+ xs match {
118
+ case xs : Tuple12 [_, _, _, _, _, _, _, _, _, _, _, _] => xs
119
+ case xs => Tuple12 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ))
120
+ }
121
+ case 13 =>
122
+ xs match {
123
+ case xs : Tuple13 [_, _, _, _, _, _, _, _, _, _, _, _, _] => xs
124
+ case xs => Tuple13 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ))
125
+ }
126
+ case 14 =>
127
+ xs match {
128
+ case xs : Tuple14 [_, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
129
+ case xs => Tuple14 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ))
130
+ }
131
+ case 15 =>
132
+ xs match {
133
+ case xs : Tuple15 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
134
+ case xs => Tuple15 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ))
135
+ }
136
+ case 16 =>
137
+ xs match {
138
+ case xs : Tuple16 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
139
+ case xs => Tuple16 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ), xs.productElement(15 ))
140
+ }
141
+ case 17 =>
142
+ xs match {
143
+ case xs : Tuple17 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
144
+ case xs => Tuple17 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ), xs.productElement(15 ), xs.productElement(16 ))
145
+ }
146
+ case 18 =>
147
+ xs match {
148
+ case xs : Tuple18 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
149
+ case xs => Tuple18 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ), xs.productElement(15 ), xs.productElement(16 ), xs.productElement(17 ))
150
+ }
151
+ case 19 =>
152
+ xs match {
153
+ case xs : Tuple19 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
154
+ case xs => Tuple19 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ), xs.productElement(15 ), xs.productElement(16 ), xs.productElement(17 ), xs.productElement(18 ))
155
+ }
156
+ case 20 =>
157
+ xs match {
158
+ case xs : Tuple20 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
159
+ case xs => Tuple20 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ), xs.productElement(15 ), xs.productElement(16 ), xs.productElement(17 ), xs.productElement(18 ), xs.productElement(19 ))
160
+ }
161
+ case 21 =>
162
+ xs match {
163
+ case xs : Tuple21 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
164
+ case xs => Tuple21 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ), xs.productElement(15 ), xs.productElement(16 ), xs.productElement(17 ), xs.productElement(18 ), xs.productElement(19 ), xs.productElement(20 ))
165
+ }
166
+ case 22 =>
167
+ xs match {
168
+ case xs : Tuple22 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => xs
169
+ case xs => Tuple22 (xs.productElement(0 ), xs.productElement(1 ), xs.productElement(2 ), xs.productElement(3 ), xs.productElement(4 ), xs.productElement(5 ), xs.productElement(6 ), xs.productElement(7 ), xs.productElement(8 ), xs.productElement(9 ), xs.productElement(10 ), xs.productElement(11 ), xs.productElement(12 ), xs.productElement(13 ), xs.productElement(14 ), xs.productElement(15 ), xs.productElement(16 ), xs.productElement(17 ), xs.productElement(18 ), xs.productElement(19 ), xs.productElement(20 ), xs.productElement(21 ))
170
+ }
171
+ case _ =>
172
+ xs match {
173
+ case xs : TupleXXL => xs
174
+ case xs => TupleXXL (xs.productIterator.map(_.asInstanceOf [Object ]).toArray)
175
+ }
176
+ }).asInstanceOf [T ]
177
+
178
+
60
179
def dynamicToArray (self : Tuple ): Array [Object ] = (self : Any ) match {
61
180
case self : Unit =>
62
181
scala.runtime.DynamicTuple .empty$Array
0 commit comments