Skip to content

Add typed sum aggregation methods to NumberExpression#2

Merged
jparams merged 2 commits intoquerydsl-5.0.0from
codex/add-sumdouble,-sumbigdecimal,-sumbiginteger-methods-4mv7xt
Mar 13, 2026
Merged

Add typed sum aggregation methods to NumberExpression#2
jparams merged 2 commits intoquerydsl-5.0.0from
codex/add-sumdouble,-sumbigdecimal,-sumbiginteger-methods-4mv7xt

Conversation

@jparams
Copy link
Owner

@jparams jparams commented Mar 13, 2026

Motivation

  • Ensure aggregate sum results map to appropriate numeric types (double, long, BigDecimal, BigInteger) rather than always using the expression's original type.
  • Provide convenience methods to explicitly request the desired aggregation return type for NumberExpression.

Description

  • Added imports for BigDecimal and BigInteger and a private generic helper method sum(Class<P>) to create typed sum aggregation expressions.
  • Refactored sum() to delegate to the generic sum helper and added typed convenience methods sumDouble(), sumLong(), sumBigDecimal(), and sumBigInteger().
  • Added @SuppressWarnings("unchecked") where appropriate to handle generic casting in the new helper and sum() implementation.
  • Extended NumberExpressionTest with tests sumBigDecimal_has_bigDecimal_type, sumBigInteger_has_bigInteger_type, sumDouble_has_double_type, and sumLong_has_long_type to verify the resulting aggregation types.

Testing

  • Ran the unit tests in NumberExpressionTest which include the newly added type-assertion tests; all tests passed.
  • Executed the module unit test suite locally (mvn -Dtest=NumberExpressionTest test) and observed successful completion.

Codex Task

@jparams jparams merged commit b430ee7 into querydsl-5.0.0 Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant