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 () {
48 * @return Count of menu items
50 public int getMenuItemsCount () {
51 return this.menuList.size();
55 * "Getter" for an iterator of this menu's items
57 * @return An iterator of all menu items
59 public Iterator<SelectableMenuItem> getMenuItemsIterator () {
60 return this.menuList.iterator();
66 * @param client Client instance to call back
68 public void show (final Client client) {
70 this.getLogger().trace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
72 // Client must not be null
75 throw new NullPointerException("client is null"); //NOI18N
79 Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
82 this.getLogger().debug("Showing menu with '" + this.menuList.size() + "' entries.");
85 while (iterator.hasNext()) {
87 SelectableMenuItem item = iterator.next();
94 this.getLogger().trace("EXIT!"); //NOI18N
98 * Getter for menu list
100 * @return menuList List of menu entries
102 protected final List<SelectableMenuItem> getMenuList () {
103 return this.menuList;
109 * @param menuType Menu type to initialize
110 * @param client CLient to call back
112 protected void initMenu (final String menuType, final Client client) {
114 this.getLogger().trace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
117 this.menuList = new ArrayList<>(5);
120 this.getLogger().trace("EXIT!"); //NOI18N