Skip to content

Commit 292ffe7

Browse files
Add field-level amount representation for Joda-Money module (#77)
1 parent 6735de9 commit 292ffe7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

joda-money/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,22 @@ ObjectMapper mapper = JsonMapper.builder()
6262
.addModule(new JodaMoneyModule().withAmountRepresentation(AmountRepresentation.DECIMAL_STRING))
6363
.build();
6464
```
65+
66+
#### Field-level amount representation
67+
68+
The `@JodaMoney` annotation allows you to override the amount representation on a per-field basis, taking precedence over the module-level configuration:
69+
70+
```java
71+
public class Payment {
72+
@JodaMoney(amountRepresentation = AmountRepresentation.DECIMAL_STRING)
73+
private Money amount;
74+
75+
@JodaMoney(amountRepresentation = AmountRepresentation.MINOR_CURRENCY_UNIT)
76+
private Money fee;
77+
78+
// This field uses the module-level configuration
79+
private Money tax;
80+
}
81+
```
82+
83+
The annotation can be applied to fields, getter/setter methods, and constructor parameters. If not specified or set to `AmountRepresentation.DEFAULT`, the property will use the module-level configuration.

0 commit comments

Comments
 (0)