2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.menu;
19 import java.text.MessageFormat;
20 import java.util.ArrayList;
21 import java.util.Iterator;
22 import java.util.List;
23 import org.mxchange.addressbook.BaseFrameworkSystem;
24 import org.mxchange.addressbook.client.Client;
25 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
29 * @author Roland Haeder
31 public class BaseMenu extends BaseFrameworkSystem {
36 private List<SelectableMenuItem> menuList;
39 * No instance from this object
41 protected BaseMenu () {
47 * @return Count of menu items
49 public int getMenuItemsCount () {
50 return this.menuList.size();
54 * "Getter" for an iterator of this menu's items
56 * @return An iterator of all menu items
58 public Iterator<SelectableMenuItem> getMenuItemsIterator () {
59 return this.menuList.iterator();
65 * @param client Client instance to call back
67 public void show (final Client client) {
69 this.getLogger().trace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
71 // Client must not be null
74 throw new NullPointerException("client is null"); //NOI18N
78 Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
81 this.getLogger().debug("Showing menu with '" + this.menuList.size() + "' entries.");
84 while (iterator.hasNext()) {
86 SelectableMenuItem item = iterator.next();
93 this.getLogger().trace("EXIT!"); //NOI18N
97 * Getter for menu list
99 * @return menuList List of menu entries
101 protected final List<SelectableMenuItem> getMenuList () {
102 return this.menuList;
108 * @param menuType Menu type to initialize
109 * @param client CLient to call back
111 protected void initMenu (final String menuType, final Client client) {
113 this.getLogger().trace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
116 this.menuList = new ArrayList<>(5);
119 this.getLogger().trace("EXIT!"); //NOI18N