Skip to content

Commit

Permalink
JS-2145 JExpression.fromNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Zschimmer committed Sep 11, 2024
1 parent a40d111 commit 2c63518
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,30 @@ object JExpression extends JJsonable.Companion[JExpression]:
def fromString(@Nonnull string: String): JExpression =
JExpression(StringConstant(string))

/** Returns the string as a NumericConstant Expression. */
@deprecated("Use fromNumber(java.math.BigDecimal)", "v2.7.2")
@Deprecated
@Nonnull
/** Returns the number as a NumericConstant Expression. */
def fromNumber(@Nonnull number: BigDecimal): JExpression =
JExpression(NumericConstant(number))

/** Returns the string as a BooleanConstant Expression. */
@Nonnull
/** Returns the number as a NumericConstant Expression. */
def fromNumber(@Nonnull number: java.math.BigDecimal): JExpression =
JExpression(NumericConstant(BigDecimal(number)))

@Nonnull
/** Returns the boolean as a BooleanConstant Expression. */
def fromBoolean(@Nonnull boolean: Boolean): JExpression =
JExpression(BooleanConstant(boolean))

/** Returns the string as a ListExpr. */
@Nonnull
/** Returns the values as a ListExpr. */
def fromIterable(@Nonnull values: java.lang.Iterable[JExpression]): JExpression =
JExpression(ListExpr(values.asScala.view.map(_.asScala).toList))

/** Returns the string as an ObjectExpr. */
@Nonnull
/** Returns the map as an ObjectExpr. */
def fromMap(@Nonnull keyToExpr: java.util.Map[String, JExpression]): JExpression =
JExpression(ObjectExpr(keyToExpr.asScala.view.mapValues(_.asScala).toMap))

Expand Down

0 comments on commit 2c63518

Please sign in to comment.