stevedlawrence commented on a change in pull request #667:
URL: https://github.com/apache/daffodil/pull/667#discussion_r736495817
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ChoiceCombinator.scala
##########
@@ -83,29 +80,18 @@ case class ChoiceCombinator(ch: ChoiceTermBase,
alternatives: Seq[Gram])
}
} else {
//Verify that every alternative has some form of branch key
- alternatives.map { alt =>
+ alternatives.foreach { alt =>
val keyTerm = alt.context.asInstanceOf[Term]
val hasBranchKey =
keyTerm.findPropertyOption("choiceBranchKey").isDefined
val hasBranchKeyRanges =
keyTerm.findPropertyOption("choiceBranchKeyRanges").isDefined
- if (!hasBranchKey && !hasBranchKeyRanges &&
ch.defaultableChoiceBranchKeyKind != ChoiceKeyKindType.ByType) {
+ if (!hasBranchKey && !hasBranchKeyRanges) {
keyTerm.SDE("Neither dfdl:choiceBranchKey nor
dfdlx:choiceBranchKeyRanges is defined.")
}
}
val dispatchBranchKeyValueTuples: Seq[(String, Gram)] =
alternatives.flatMap { alt =>
val keyTerm = alt.context.asInstanceOf[Term]
val uncookedBranchKeys =
- ch.defaultableChoiceBranchKeyKind match {
- case ChoiceKeyKindType.ByType => {
- val keyTerm_ = keyTerm.asInstanceOf[ElementBase]
- val st = keyTerm_.simpleType
- val aa = st.optRepValueSet
- val repValueSet = keyTerm_.simpleType.optRepValueSet.get
- val ans =
repValueSet.valueSet.toSeq.map(_.getAnyRef.toString).mkString(" ")
- ans
- }
- case ChoiceKeyKindType.Explicit | ChoiceKeyKindType.Implicit =>
keyTerm.findPropertyOption("choiceBranchKey").toOption.getOrElse("")
- case ChoiceKeyKindType.Speculative =>
Assert.invariantFailed("Cannot have choiceKeyKind==speculative with direct
dispatch")
- }
+ keyTerm.findPropertyOption("choiceBranchKey").toOption.getOrElse("")
Review comment:
I know you just copied this from above, but thoughts on removing the
`getOrElse("")` and then changing the below to using an `Option`? That feels
safer to represent no value than empty string.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]