stevedlawrence commented on code in PR #1199:
URL: https://github.com/apache/daffodil/pull/1199#discussion_r1545371322
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dpath/ComparisonOps.scala:
##########
@@ -17,10 +17,42 @@
package org.apache.daffodil.runtime1.dpath
+import org.apache.daffodil.lib.exceptions.Assert
import org.apache.daffodil.lib.util.Numbers._
+import org.apache.daffodil.runtime1.dpath.NodeInfo.PrimType
import org.apache.daffodil.runtime1.infoset.DataValue.DataValueBool
import org.apache.daffodil.runtime1.infoset.DataValue.DataValuePrimitive
+object ComparisonOps {
+ lazy val forType: Map[
Review Comment:
Another option might be to create a new case class and make that the value
of the map, e.g.:
```scala
case class ComparisonOps(eq: ComparisonOp, ne: ComparisonOp, lt:
ComparisonOp, ...)
...
Map(
PrimType.Boolean -> ComparisonOps(EQ_Compare, NE_Compare, LT_Boolean, ...),
...
)
```
Then uses become something like:
```scala
val compOps = ComparisonOps.forType(targetTypeForSubExpr)
val compare = if (isExclusive) compOps.lt else compOps.le
```
It's a little more verbose, but using it is a bit more clear and less prone
to errors since it's impossible for callers of `forType` to get the order of
the 6-tuple wrong.
--
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]