Skip to content

Commit

Permalink
Make findEqualValueOfWellKnownType catch exceptions #2554 (#2555)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaMuravjov authored Aug 25, 2023
1 parent 4a75abc commit de1712a
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,14 @@ class UtModelConstructor(
?: constructCompositeModel(value, remainingDepth)
}

private fun findEqualValueOfWellKnownType(value: Any): Pair<Any, ClassId>? = when (value) {
is List<*> -> ArrayList(value) to listClassId
is Set<*> -> LinkedHashSet(value) to setClassId
is Map<*, *> -> LinkedHashMap(value) to mapClassId
else -> null
}
private fun findEqualValueOfWellKnownType(value: Any): Pair<Any, ClassId>? = runCatching {
when (value) {
is List<*> -> ArrayList(value) to listClassId
is Set<*> -> LinkedHashSet(value) to setClassId
is Map<*, *> -> LinkedHashMap(value) to mapClassId
else -> null
}
}.getOrNull()

/**
* Constructs custom UtModel but does it only for predefined list of classes.
Expand Down

0 comments on commit de1712a

Please sign in to comment.