Skip to content

Commit

Permalink
Use isStringEnumShape, reorder when conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis committed Aug 8, 2024
1 parent 8281792 commit 7a91d95
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,15 @@ open class XmlParserGenerator(
val parseFn = when {
target.type == ShapeType.BLOB -> writer.format("#T { it.#T() } ", RuntimeTypes.Serde.parse, RuntimeTypes.Core.Text.Encoding.decodeBase64Bytes)
target.type == ShapeType.BOOLEAN -> writer.format("#T()", RuntimeTypes.Serde.parseBoolean)
target.type == ShapeType.STRING && !target.hasTrait<EnumTrait>() -> {
target.isStringEnumShape -> {
if (!textExprIsResult) {
writer.write("#T.fromValue(#L)", ctx.symbolProvider.toSymbol(target), textExpr)
return
} else {
writer.format("#T { #T.fromValue(it) } ", RuntimeTypes.Serde.parse, ctx.symbolProvider.toSymbol(target))
}
}
target.type == ShapeType.STRING -> {
if (!textExprIsResult) {
writer.write(textExpr)
return
Expand All @@ -601,14 +609,6 @@ open class XmlParserGenerator(
target.type == ShapeType.DOUBLE -> writer.format("#T()", RuntimeTypes.Serde.parseDouble)
target.type == ShapeType.BIG_DECIMAL -> writer.format("#T()", RuntimeTypes.Serde.parseBigDecimal)
target.type == ShapeType.BIG_INTEGER -> writer.format("#T()", RuntimeTypes.Serde.parseBigInteger)
target.type == ShapeType.ENUM || (target.type == ShapeType.STRING && target.hasTrait<EnumTrait>()) -> {
if (!textExprIsResult) {
writer.write("#T.fromValue(#L)", ctx.symbolProvider.toSymbol(target), textExpr)
return
} else {
writer.format("#T { #T.fromValue(it) } ", RuntimeTypes.Serde.parse, ctx.symbolProvider.toSymbol(target))
}
}
target.type == ShapeType.INT_ENUM -> {
writer.format("#T { #T.fromValue(it.toInt()) } ", RuntimeTypes.Serde.parse, ctx.symbolProvider.toSymbol(target))
}
Expand Down

0 comments on commit 7a91d95

Please sign in to comment.