]> git.mxchange.org Git - addressbook-swing.git/blobdiff - src/org/mxchange/addressbook/menu/MenuTools.java
Added email address for author
[addressbook-swing.git] / src / org / mxchange / addressbook / menu / MenuTools.java
index d5f4695218ef02ae3ff8147958af94e94339109a..a8bb6109892686991b05bd5717afa4b789707d68 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2016 Roland Haeder
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,37 +18,37 @@ 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.exceptions.MenuInitializationException;
 
 /**
- *
- * @author Roland Haeder
+ * Menu utilities
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
  */
 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
+        * <p>
         * @return An array with available access chars
+        * <p>
+        * @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 +62,11 @@ public class MenuTools extends BaseAddressbookSystem {
                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++;