-
Notifications
You must be signed in to change notification settings - Fork 7
ResourceBundle
h908714124 edited this page Jun 12, 2021
·
11 revisions
Call the withMessages(Map<String, String>) method on the generated parser,
with a map created from the bundle:
public static void main(String[] args) {
ResourceBundle bundle = ResourceBundle.getBundle("myResource");
DeleteCommand command = new DeleteCommandParser().parse(args)
.orElseThrow(notSuccess ->
StandardErrorHandler.builder(notSuccess)
.withMessages(toMap(bundle))
.build().handle());
// ...
}
private static Map<String, String> toMap(ResourceBundle bundle) {
return Collections.list(bundle.getKeys()).stream()
.collect(Collectors.toMap(Function.identity(), bundle::getString));
}