]> git.mxchange.org Git - addressbook-swing.git/blobdiff - src/org/mxchange/addressbook/menu/BaseMenu.java
Updated copyright year
[addressbook-swing.git] / src / org / mxchange / addressbook / menu / BaseMenu.java
index a02c885136f9d6911c7fc03130ba54ef7d375b12..bbd7414863a229f049af6dd89b5be93f9dda6f34 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2016 - 2022 Free Software Foundation
  *
  * 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,18 +18,19 @@ package org.mxchange.addressbook.menu;
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.addressbook.BaseAddressbookSystem;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
-import org.mxchange.jcore.BaseFrameworkSystem;
 import org.mxchange.jcore.client.Client;
 
 /**
- *
- * @author Roland Haeder
+ * A general menu class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
  */
-public class BaseMenu extends BaseFrameworkSystem {
+public abstract class BaseMenu extends BaseAddressbookSystem implements Menu {
 
        /**
         * Menu list
@@ -42,32 +43,20 @@ public class BaseMenu extends BaseFrameworkSystem {
        protected BaseMenu () {
        }
 
-       /**
-        * Size of menu items
-        * <p>
-        * @return Count of menu items
-        */
+       @Override
        public int getMenuItemsCount () {
                return this.menuList.size();
        }
 
-       /**
-        * "Getter" for an iterator of this menu's items
-        * <p>
-        * @return An iterator of all menu items
-        */
+       @Override
        public Iterator<SelectableMenuItem> getMenuItemsIterator () {
                return this.menuList.iterator();
        }
 
-       /**
-        * Shows this menu
-        * <p>
-        * @param client Client instance to call back
-        */
+       @Override
        public void show (final Client client) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
 
                // Client must not be null
                if (null == client) {
@@ -79,7 +68,7 @@ public class BaseMenu extends BaseFrameworkSystem {
                Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
 
                // Debug message
-               this.getLogger().debug("Showing menu with '" + this.menuList.size() + "' entries.");
+               this.getLoggerBeanLocal().logDebug("Showing menu with '" + this.menuList.size() + "' entries.");
 
                // Output all menus
                while (iterator.hasNext()) {
@@ -87,11 +76,11 @@ public class BaseMenu extends BaseFrameworkSystem {
                        SelectableMenuItem item = iterator.next();
 
                        // Show this item
-                       item.show((AddressbookClient) client);
+                       item.show(client);
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -99,8 +88,8 @@ public class BaseMenu extends BaseFrameworkSystem {
         * <p>
         * @return      menuList List of menu entries
         */
-       protected final List<SelectableMenuItem> getMenuList () {
-               return this.menuList;
+       protected List<SelectableMenuItem> getMenuList () {
+               return Collections.unmodifiableList(this.menuList);
        }
 
        /**
@@ -111,12 +100,12 @@ public class BaseMenu extends BaseFrameworkSystem {
         */
        protected void initMenu (final String menuType, final Client client) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
 
                // Init menu list
                this.menuList = new ArrayList<>(5);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 }