X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fmxchange%2Faddressbook%2Fmenu%2FBaseMenu.java;h=d39e1be37e55e78f9711c2ddff67ca2ed7b4532b;hb=528eeece943480f5a89d0067cfb6e4cb86f528b5;hp=f5548207938051251ef209dfec785099e29c3b17;hpb=f2010ed4e24bb3e08ee7884184ee23f35193200d;p=addressbook-swing.git diff --git a/src/org/mxchange/addressbook/menu/BaseMenu.java b/src/org/mxchange/addressbook/menu/BaseMenu.java index f554820..d39e1be 100644 --- a/src/org/mxchange/addressbook/menu/BaseMenu.java +++ b/src/org/mxchange/addressbook/menu/BaseMenu.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Roland Haeder + * Copyright (C) 2016 - 2020 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.BaseAddressbookSystem; -import org.mxchange.addressbook.client.AddressbookClient; import org.mxchange.addressbook.menu.item.SelectableMenuItem; import org.mxchange.jcore.client.Client; /** - * - * @author Roland Haeder + * A general menu class + *

+ * @author Roland Häder */ -public class BaseMenu extends BaseAddressbookSystem { +public abstract class BaseMenu extends BaseAddressbookSystem implements Menu { /** * Menu list @@ -42,35 +43,23 @@ public class BaseMenu extends BaseAddressbookSystem { protected BaseMenu () { } - /** - * Size of menu items - * - * @return Count of menu items - */ + @Override public int getMenuItemsCount () { return this.menuList.size(); } - /** - * "Getter" for an iterator of this menu's items - * - * @return An iterator of all menu items - */ + @Override public Iterator getMenuItemsIterator () { return this.menuList.iterator(); } - /** - * Shows this menu - * - * @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 (client == null) { + if (null == client) { // Abort here throw new NullPointerException("client is null"); //NOI18N } @@ -79,7 +68,7 @@ public class BaseMenu extends BaseAddressbookSystem { Iterator 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,36 +76,36 @@ public class BaseMenu extends BaseAddressbookSystem { 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 } /** * Getter for menu list - * + *

* @return menuList List of menu entries */ - protected final List getMenuList () { - return this.menuList; + protected List getMenuList () { + return Collections.unmodifiableList(this.menuList); } /** * Initializes menu - * + *

* @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().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 } }