Skip to content

Conversation

@sri-adarsh-kumar
Copy link
Contributor

Implements per-property override of amount representation to complement the module-level default introduced in PR #17.

Changes:

  • Add DEFAULT value to AmountRepresentation enum to represent "inherit module config"
  • Add @jsonmoney annotation for field-level configuration
  • Make MoneySerializer and MoneyDeserializer contextual to support per-property resolution
  • Support @jsonformat(shape=...) mapping: STRING→DECIMAL_STRING, NUMBER/NUMBER_FLOAT→DECIMAL_NUMBER, NUMBER_INT→MINOR_CURRENCY_UNIT
  • Precedence: @jsonmoney > @jsonformat > module default > built-in default
  • Full mix-in support via Jackson's standard BeanProperty API
  • Maintain backward compatibility for unannotated fields

Tests:

  • Add MoneyFieldLevelRepresentationTest with 12 tests covering field/getter/constructor annotations, mixed configurations, precedence, and mix-ins
  • Add MoneyFormatShapeMappingTest with 9 tests covering shape mappings and multiple fields
  • All 94 tests pass (21 new, 73 existing with no regression)

Fixes #18

🤖 Generated with Claude Code

sri-adarsh-kumar and others added 4 commits October 21, 2025 16:11
Implements per-property override of amount representation to complement
the module-level default introduced in PR FasterXML#17.

Changes:
- Add DEFAULT value to AmountRepresentation enum to represent "inherit module config"
- Add @jsonmoney annotation for field-level configuration
- Make MoneySerializer and MoneyDeserializer contextual to support per-property resolution
- Support @jsonformat(shape=...) mapping: STRING→DECIMAL_STRING, NUMBER/NUMBER_FLOAT→DECIMAL_NUMBER, NUMBER_INT→MINOR_CURRENCY_UNIT
- Precedence: @jsonmoney > @jsonformat > module default > built-in default
- Full mix-in support via Jackson's standard BeanProperty API
- Maintain backward compatibility for unannotated fields

Tests:
- Add MoneyFieldLevelRepresentationTest with 12 tests covering field/getter/constructor annotations, mixed configurations, precedence, and mix-ins
- Add MoneyFormatShapeMappingTest with 9 tests covering shape mappings and multiple fields
- All 94 tests pass (21 new, 73 existing with no regression)

Fixes FasterXML#18

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Update package structure from com.fasterxml.jackson to tools.jackson
- Adapt MoneySerializer for Jackson 3.x API (SerializationContext, JacksonException)
- Adapt MoneyDeserializer for Jackson 3.x API
- Update JsonMoney annotation package
- Update test files package declarations and imports
- Maintain field-level amount representation feature compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Fix Jackson 3.x API compatibility: use MapperBuilder.addMixIn() instead of ObjectMapper.addMixIn()
- Replace AssertJ assertions with JUnit assertions (assertTrue, assertEquals)
- Fix import statements to use correct Jackson 3.x package names
- Update MoneySerializer and MoneyDeserializer to implement contextual serialization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link
Member

@cowtowncoder cowtowncoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable; couple of changes needed but nothing major. Can go in 3.1.0 (API addition with new enum type).

@cowtowncoder
Copy link
Member

@sri-adarsh-kumar we have CCLA for Zalando so you would be covered, right? If so, no need for individual CLA.

@cowtowncoder cowtowncoder added joda-money Issue related joda-money datatype module cla-received Marker to denote that required CLA received labels Oct 21, 2025
cowtowncoder and others added 2 commits October 21, 2025 20:22
Renamed the @jsonmoney annotation to @JodaMoney for better alignment with the module naming convention. This change updates:
- Annotation interface name from JsonMoney to JodaMoney
- All references in serializer and deserializer classes
- All test cases and documentation examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@sri-adarsh-kumar sri-adarsh-kumar marked this pull request as ready for review October 22, 2025 18:07
@cowtowncoder
Copy link
Member

Looks good, will try to do proper review soon, to merge in 3.x for 3.1.0

*
* @see AmountRepresentation
* @see JodaMoneyModule#withAmountRepresentation(AmountRepresentation)
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SInCE 3.1

Copy link
Member

@cowtowncoder cowtowncoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- I can add missing @since annotations.

@cowtowncoder cowtowncoder changed the title Add field-level amount representation for Joda-Money Add field-level amount representation for Joda-Money (@JodaMoney annotation) Oct 25, 2025
@cowtowncoder cowtowncoder merged commit 6735de9 into FasterXML:3.x Oct 25, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-received Marker to denote that required CLA received joda-money Issue related joda-money datatype module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvement: Allow selection of amount representation for individual Joda Money fields

2 participants