Skip to content

Commit

Permalink
chore: Using conventional name and renaming isPolimorphic
Browse files Browse the repository at this point in the history
  • Loading branch information
LichtHund committed Dec 5, 2023
1 parent 7e227ed commit 20fc0c1
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public sealed class Hocon(

}

private inner class ConfigReader(val conf: Config, private val isPolymorph: Boolean = false) : ConfigConverter<String>() {
private inner class ConfigReader(val conf: Config, private val isPolymorphic: Boolean = false) : ConfigConverter<String>() {
private var ind = -1

override fun decodeElementIndex(descriptor: SerialDescriptor): Int {
Expand All @@ -162,10 +162,8 @@ public sealed class Hocon(
if (parentName.isEmpty()) childName else "$parentName.$childName"

override fun SerialDescriptor.getTag(index: Int): String {
return if (!isPolymorph) composeName(
currentTagOrNull.orEmpty(),
getConventionElementName(index, useConfigNamingConvention)
) else getElementName(index)
val conventionName = getConventionElementName(index, useConfigNamingConvention)
return if (!isPolymorphic) composeName(currentTagOrNull.orEmpty(), conventionName) else conventionName
}

override fun decodeNotNullMark(): Boolean {
Expand Down Expand Up @@ -215,8 +213,7 @@ public sealed class Hocon(

override fun beginStructure(descriptor: SerialDescriptor): CompositeDecoder =
when {
// Polymorph should always be object-like I believe?
descriptor.kind.objLike -> ConfigReader(conf, isPolymorph = true)
descriptor.kind.objLike -> ConfigReader(conf, isPolymorphic = true)
else -> this
}

Expand Down

0 comments on commit 20fc0c1

Please sign in to comment.