andreachild commented on code in PR #3153:
URL: https://github.com/apache/tinkerpop/pull/3153#discussion_r2230275440
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/NumberHelper.java:
##########
@@ -721,6 +723,86 @@ public static Number coerceTo(final Number a, final
Class<? extends Number> claz
return a;
}
+ /**
+ * Casts the given number to the specified numeric type if it can fit into
it.
+ * Otherwise, throw.
+ *
+ * @param a the number to be cast
+ * @param numberToken the number token denoting the desired type to cast
+ * @return the number cast to the specified type
+ * @throws IllegalArgumentException if the specified numeric type is
unsupported
+ * @throws ArithmeticException if the number overflows
+ */
+ public static Number castTo(final Number a, final N numberToken) {
Review Comment:
There's an existing `coerceTo` method which has similar casting logic (but
that one instead of throwing on overflow, will return the original type). I am
wondering if the logic between `coerceTo` and `castTo` should be made
consistent (can `castTo` delegate most of the logic to `coerceTo`?) and if it's
a problem if they are inconsistent.
--
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]