diff --git a/pom.xml b/pom.xml index 9bf7b7e..36404d9 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,10 @@ Tim Molter + + Sarp Güney Başaraner + https://github.com/sgbasaraner + Gabriel Bauman https://github.com/gabrielbauman diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7eda4fa..254fced 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -12,6 +12,9 @@ Add Tidelift commercial support and security policy. + + Enhance null checks. + diff --git a/src/main/java/org/joda/money/format/MoneyFormatter.java b/src/main/java/org/joda/money/format/MoneyFormatter.java index 01fcdb4..827b184 100644 --- a/src/main/java/org/joda/money/format/MoneyFormatter.java +++ b/src/main/java/org/joda/money/format/MoneyFormatter.java @@ -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); } @@ -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; }