All KiwiPreconditions methods should accept the same message template placeholders #984
Closed
12 tasks done
Labels
enhancement
A request for change or improvement to an existing feature
Milestone
The following methods in
KiwiPreconditions
only accept%s
as the placeholder in error message templates:checkPositive(int value, String errorMessageTemplate, Object... errorMessageArgs)
checkPositive(long value, String errorMessageTemplate, Object... errorMessageArgs)
checkPositiveOrZero(int value, String errorMessageTemplate, Object... errorMessageArgs)
checkPositiveOrZero(long value, String errorMessageTemplate, Object... errorMessageArgs)
requirePositive(int value, String errorMessageTemplate, Object... errorMessageArgs)
requirePositive(long value, String errorMessageTemplate, Object... errorMessageArgs)
requirePositiveOrZero(int value, String errorMessageTemplate, Object... errorMessageArgs)
requirePositiveOrZero(long value, String errorMessageTemplate, Object... errorMessageArgs)
checkValidPort(int port, String errorMessageTemplate, Object... errorMessageArgs)
requireValidPort(int port, String errorMessageTemplate, Object... errorMessageArgs)
checkValidNonZeroPort(int port, String errorMessageTemplate, Object... errorMessageArgs)
requireValidNonZeroPort(int port, String errorMessageTemplate, Object... errorMessageArgs)
The reason is that they directly use Guava's
Preconditions
which accepts only%s
placeholders.Other methods in
KiwiPreconditions
useKiwiStrings#format
under the covers and therefore accept either%s
or{}
as placeholders (since that is howKiwiStrings#format
behaves).We should change the above methods to work like the ones that accept either placeholder, and document the behavior as the other methods do already, e.g. they say the template behaves according to how KiwiStrings#format(String, Object...) handles placeholders.
This isn't really a 🐞 ; it's more of an omission, which also isn't documented, so I've labeled it as an enhancement instead.
All tests of methods that use a message template should verify that both placeholders work.
The text was updated successfully, but these errors were encountered: