]> git.mxchange.org Git - addressbook-swing.git/blobdiff - src/org/mxchange/addressbook/menu/MenuTools.java
auto-reformatted most project files
[addressbook-swing.git] / src / org / mxchange / addressbook / menu / MenuTools.java
index ee03267c4299383778f9cd6cb8d29611ae3d9b5e..87f8c114733b6ef686d8f7a6d35638c0fc5d092e 100644 (file)
@@ -18,37 +18,34 @@ package org.mxchange.addressbook.menu;
 
 import java.util.Iterator;
 import java.util.Map;
-import org.apache.logging.log4j.Logger;
+import org.mxchange.addressbook.BaseAddressbookSystem;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
-import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcore.exceptions.MenuInitializationException;
 
 /**
- *
+ * Menu utilities
+ * <p>
  * @author Roland Haeder
  */
-public class MenuTools extends BaseFrameworkSystem {
+public class MenuTools extends BaseAddressbookSystem {
 
        /**
         * Gets an array with all available access keys back from given menu map.
         * This can later be handle to the client's enterChar() method.
-        *
+        * <p>
         * @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) {
-               // Get logger
-               Logger logger = new MenuTools().getLogger();
-
+       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
-                       logger.error("Menu '" + menuType + "' not found.");
-                       System.exit(1);
+                       throw new MenuInitializationException(menu, menuType);
                }
 
                // Get iterator
@@ -62,11 +59,11 @@ public class MenuTools extends BaseFrameworkSystem {
                while (iterator.hasNext()) {
                        // Get item
                        SelectableMenuItem item = iterator.next();
-                       //* NOISY-DEBUG: */ logger.debug("item=" + item);
+                       //* NOISY-DEBUG: */ logger.logDebug("item=" + item);
 
                        // Get access key from item and add it to the array
                        accessKeys[i] = item.getAccessKey();
-                       //* NOISY-DEBUG: */ logger.debug("accessKeys[" + i + "]=" + accessKeys[i]);
+                       //* NOISY-DEBUG: */ logger.logDebug("accessKeys[" + i + "]=" + accessKeys[i]);
 
                        // Increment counter
                        i++;