@@ -113,7 +113,10 @@ class UtModelConstructor(
113
113
is Long ,
114
114
is Float ,
115
115
is Double ,
116
- is Boolean -> if (classId.isPrimitive) UtPrimitiveModel (value) else constructFromAny(value, remainingDepth)
116
+ is Boolean -> {
117
+ if (classId.isPrimitive) UtPrimitiveModel (value)
118
+ else constructFromAny(value, classId, remainingDepth)
119
+ }
117
120
118
121
is ByteArray -> constructFromByteArray(value, remainingDepth)
119
122
is ShortArray -> constructFromShortArray(value, remainingDepth)
@@ -127,7 +130,7 @@ class UtModelConstructor(
127
130
is Enum <* > -> constructFromEnum(value)
128
131
is Class <* > -> constructFromClass(value)
129
132
is BaseStream <* , * > -> constructFromStream(value)
130
- else -> constructFromAny(value, remainingDepth)
133
+ else -> constructFromAny(value, classId, remainingDepth)
131
134
}
132
135
}
133
136
@@ -287,11 +290,22 @@ class UtModelConstructor(
287
290
/* *
288
291
* First tries to construct UtAssembleModel. If failure, constructs UtCompositeModel.
289
292
*/
290
- private fun constructFromAny (value : Any , remainingDepth : Long ): UtModel =
293
+ private fun constructFromAny (value : Any , classId : ClassId , remainingDepth : Long ): UtModel =
291
294
constructedObjects.getOrElse(value) {
292
- tryConstructCustomModel(value, remainingDepth) ? : constructCompositeModel(value, remainingDepth)
295
+ tryConstructCustomModel(value, remainingDepth)
296
+ ? : findEqualValueOfWellKnownType(value)
297
+ ?.takeIf { classId.jClass.isInstance(it) }
298
+ ?.let { tryConstructCustomModel(it, remainingDepth) }
299
+ ? : constructCompositeModel(value, remainingDepth)
293
300
}
294
301
302
+ private fun findEqualValueOfWellKnownType (value : Any ): Any? = when (value) {
303
+ is List <* > -> ArrayList (value)
304
+ is Set <* > -> LinkedHashSet (value)
305
+ is Map <* , * > -> LinkedHashMap (value)
306
+ else -> null
307
+ }
308
+
295
309
/* *
296
310
* Constructs custom UtModel but does it only for predefined list of classes.
297
311
*
0 commit comments