Skip to content

Commit

Permalink
Enhance null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jodastephen committed Nov 6, 2021
1 parent ce2c664 commit 7965e69
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions pom.xml
Expand Up @@ -36,6 +36,10 @@
<contributor>
<name>Tim Molter</name>
</contributor>
<contributor>
<name>Sarp Güney Başaraner</name>
<url>https://github.com/sgbasaraner</url>
</contributor>
<contributor>
<name>Gabriel Bauman</name>
<url>https://github.com/gabrielbauman</url>
Expand Down
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Expand Up @@ -12,6 +12,9 @@
<action dev="jodastephen" type="add">
Add Tidelift commercial support and security policy.
</action>
<action dev="sgbasaraner" type="fix">
Enhance null checks.
</action>
</release>
<release version="1.0.1" date="2018-08-20" description="v1.0.1">
<action dev="jodastephen" type="fix">
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/org/joda/money/format/MoneyFormatter.java
Expand Up @@ -70,10 +70,12 @@ static void checkNotNull(Object object, String message) {
* @param parsers the parsers, not null
*/
MoneyFormatter(Locale locale, MoneyPrinter[] printers, MoneyParser[] parsers) {
assert locale != null;
assert printers != null;
assert parsers != null;
assert printers.length == parsers.length;
MoneyFormatter.checkNotNull(locale, "Locale must not be null");
MoneyFormatter.checkNotNull(printers, "Printers must not be null");
MoneyFormatter.checkNotNull(parsers, "Parsers must not be null");
if (printers.length != parsers.length) {
throw new IllegalArgumentException("Printers and parsers must match");
}
this.locale = locale;
this.printerParser = new MultiPrinterParser(printers, parsers);
}
Expand All @@ -85,8 +87,8 @@ static void checkNotNull(Object object, String message) {
* @param printerParser the printer/parser, not null
*/
private MoneyFormatter(Locale locale, MultiPrinterParser printerParser) {
assert locale != null;
assert printerParser != null;
MoneyFormatter.checkNotNull(locale, "Locale must not be null");
MoneyFormatter.checkNotNull(printerParser, "PrinterParser must not be null");
this.locale = locale;
this.printerParser = printerParser;
}
Expand Down

0 comments on commit 7965e69

Please sign in to comment.