*/
package org.mxchange.addressbook.menu;
-import java.text.MessageFormat;
import java.util.Iterator;
import java.util.Map;
import org.mxchange.addressbook.BaseAddressbookSystem;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.exceptions.MenuInitializationException;
/**
* Menu utilities
* @param menus A Map with all menus and their entries
* @param menuType Menu type
* @return An array with available access chars
+ * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the menu cannot be initialized
*/
- public static char[] getAccessKeysFromMenuMap (final Map<String, Menu> menus, final String menuType) {
+ public static char[] getAccessKeysFromMenuMap (final Map<String, Menu> menus, final String menuType) throws MenuInitializationException {
// First search for the proper menu class
Menu menu = menus.get(menuType);
// Is it there?
if (!(menu instanceof Menu)) {
// Not found
- // TODO Rewrite to exception
- System.err.println(MessageFormat.format("menu is not implementing Menu: {0}", menu)); //NOI18N
- System.exit(1);
+ throw new MenuInitializationException(menu, menuType);
}
// Get iterator