1+ package org.utbot.framework.assemble
2+
3+ import org.utbot.framework.plugin.api.UtAssembleModel
4+ import org.utbot.framework.plugin.api.UtExecutableCallModel
5+ import org.utbot.framework.plugin.api.UtPrimitiveModel
6+ import org.utbot.framework.plugin.api.util.booleanClassId
7+ import org.utbot.framework.plugin.api.util.charClassId
8+ import org.utbot.framework.plugin.api.util.doubleClassId
9+ import org.utbot.framework.plugin.api.util.executableId
10+ import org.utbot.framework.plugin.api.util.floatClassId
11+ import org.utbot.framework.plugin.api.util.intClassId
12+ import org.utbot.framework.plugin.api.util.longClassId
13+ import org.utbot.framework.plugin.api.util.shortClassId
14+ import org.utbot.framework.plugin.api.util.wrapIfPrimitive
15+
16+ /* *
17+ * Creates [UtAssembleModel] of the wrapper for a given [UtPrimitiveModel].
18+ */
19+ fun assemble (model : UtPrimitiveModel ): UtAssembleModel {
20+ val modelType = model.classId
21+ val assembledModelType = wrapIfPrimitive(modelType)
22+
23+ val constructorCall = when (modelType) {
24+ shortClassId -> java.lang.Short ::class .java.getConstructor(Short ::class .java)
25+ intClassId -> java.lang.Integer ::class .java.getConstructor(Int ::class .java)
26+ longClassId -> java.lang.Long ::class .java.getConstructor(Long ::class .java)
27+ charClassId -> java.lang.Character ::class .java.getConstructor(Char ::class .java)
28+ booleanClassId -> java.lang.Boolean ::class .java.getConstructor(Boolean ::class .java)
29+ floatClassId -> java.lang.Float ::class .java.getConstructor(Float ::class .java)
30+ doubleClassId -> java.lang.Double ::class .java.getConstructor(Double ::class .java)
31+ else -> error(" Model type $modelType is void or non-primitive" )
32+ }
33+
34+ val constructorCallModel = UtExecutableCallModel (
35+ instance = null ,
36+ executable = constructorCall.executableId,
37+ params = listOf (model),
38+ returnValue = null ,
39+ )
40+
41+ return UtAssembleModel (
42+ id = null ,
43+ classId = assembledModelType,
44+ modelName = modelType.canonicalName,
45+ instantiationChain = listOf (constructorCallModel),
46+ modificationsChain = emptyList(),
47+ )
48+ }
0 commit comments