]> git.mxchange.org Git - jaddressbook-lib.git/blobdiff - src/org/mxchange/addressbook/menu/BaseMenu.java
Prepared for upcoming rewrite:
[jaddressbook-lib.git] / src / org / mxchange / addressbook / menu / BaseMenu.java
index d81c0714f877bdb74e00243e5331117002fb9527..ad8c2e593884b7f4313b83f9cc686cbed5aacbcb 100644 (file)
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.menu;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import org.mxchange.addressbook.BaseFrameworkSystem;\r
-import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.menu.item.SelectableMenuItem;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder\r
- */\r
-public class BaseMenu extends BaseFrameworkSystem {\r
-    /**\r
-     * Menu list\r
-     */\r
-    private List<SelectableMenuItem> menuList;\r
-\r
-    /**\r
-     * No instance from this object\r
-     */\r
-    protected BaseMenu () {\r
-       super();\r
-    }\r
-\r
-    /**\r
-     * Size of menu items\r
-     * @return Count of menu items\r
-     */\r
-    public int getMenuItemsCount () {\r
-       return this.menuList.size();\r
-    }\r
-\r
-    /**\r
-     * "Getter" for an iterator of this menu's items\r
-     *\r
-     * @return An iterator of all menu items\r
-     */\r
-    public Iterator<SelectableMenuItem> getMenuItemsIterator () {\r
-       return this.menuList.iterator();\r
-    }\r
-\r
-    /**\r
-     * Shows this menu\r
-     * \r
-     * @param client Client instance to call back\r
-     */\r
-    public void show (final Client client) {\r
-       // Get values\r
-       Iterator<SelectableMenuItem> iterator = this.menuList.iterator();\r
-\r
-       // Debug message\r
-       this.getLogger().debug("Showing menu with '" + this.menuList.size() + "' entries.");\r
-\r
-       // Output all menus\r
-       while (iterator.hasNext()) {\r
-           // Get item\r
-           SelectableMenuItem item = iterator.next();\r
-\r
-           // Show this item\r
-           item.show(client);\r
-       }\r
-    }\r
-\r
-    /**\r
-     * Getter for menu list\r
-     *\r
-     * @return menuList List of menu entries\r
-     */\r
-    protected final List<SelectableMenuItem> getMenuList () {\r
-       return this.menuList;\r
-    }\r
-\r
-    /**\r
-     * Initializes menu\r
-     * @param menuType Menu type to initialize\r
-     * @param client CLient to call back\r
-     */\r
-    protected void initMenu (final String menuType, final Client client) {\r
-       // Init menu list\r
-       this.menuList = new ArrayList<>(5);\r
-    }\r
-}\r
+/*
+ * Copyright (C) 2015 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.menu;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.mxchange.addressbook.BaseAddressbookSystem;
+import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class BaseMenu extends BaseAddressbookSystem {
+
+       /**
+        * Menu list
+        */
+       private List<SelectableMenuItem> menuList;
+
+       /**
+        * No instance from this object
+        */
+       protected BaseMenu () {
+       }
+
+       /**
+        * Size of menu items
+        * <p>
+        * @return Count of menu items
+        */
+       public int getMenuItemsCount () {
+               return this.menuList.size();
+       }
+
+       /**
+        * "Getter" for an iterator of this menu's items
+        * <p>
+        * @return An iterator of all menu items
+        */
+       public Iterator<SelectableMenuItem> getMenuItemsIterator () {
+               return this.menuList.iterator();
+       }
+
+       /**
+        * Shows this menu
+        * <p>
+        * @param client Client instance to call back
+        */
+       public void show (final Client client) {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
+
+               // Client must not be null
+               if (null == client) {
+                       // Abort here
+                       throw new NullPointerException("client is null"); //NOI18N
+               }
+
+               // Get values
+               Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
+
+               // Debug message
+               this.getLogger().logDebug("Showing menu with '" + this.menuList.size() + "' entries.");
+
+               // Output all menus
+               while (iterator.hasNext()) {
+                       // Get item
+                       SelectableMenuItem item = iterator.next();
+
+                       // Show this item
+                       item.show(client);
+               }
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Getter for menu list
+        * <p>
+        * @return      menuList List of menu entries
+        */
+       protected final List<SelectableMenuItem> getMenuList () {
+               return this.menuList;
+       }
+
+       /**
+        * Initializes menu
+        * <p>
+        * @param menuType      Menu type to initialize
+        * @param client CLient to call back
+        */
+       protected void initMenu (final String menuType, final Client client) {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
+
+               // Init menu list
+               this.menuList = new ArrayList<>(5);
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+}