2 * Copyright (C) 2015 Roland Haeder
\r
4 * This program is free software: you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation, either version 3 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
17 package org.mxchange.addressbook.menu.console;
\r
19 import java.util.ArrayList;
\r
20 import java.util.Iterator;
\r
21 import java.util.List;
\r
22 import org.mxchange.addressbook.BaseFrameworkSystem;
\r
23 import org.mxchange.addressbook.client.Client;
\r
24 import org.mxchange.addressbook.menu.AddressbookMenu;
\r
25 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
\r
29 * @author Roland Haeder
\r
31 public class BaseMenu extends BaseFrameworkSystem {
\r
35 private List<SelectableMenuItem> menuList;
\r
38 * No instance from this object
\r
40 protected BaseMenu () {
\r
45 * "Getter" for an iterator of this menu's items
\r
47 * @return An iterator of all menu items
\r
49 public Iterator<SelectableMenuItem> getMenuItemsIterator () {
\r
50 return this.menuList.iterator();
\r
54 * Size of menu items
\r
55 * @return Count of menu items
\r
57 public int getMenuItemsCount () {
\r
58 return this.menuList.size();
\r
64 * @param client Client instance to call back
\r
66 public void show (final Client client) {
\r
68 Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
\r
71 this.getLogger().debug("Showing menu with '" + this.menuList.size() + "' entries.");
\r
74 while (iterator.hasNext()) {
\r
76 SelectableMenuItem item = iterator.next();
\r
85 * @param menuType Menu type to initialize
\r
86 * @param client CLient to call back
\r
88 protected void initMenu (final String menuType, final Client client) {
\r
90 this.menuList = new ArrayList<>(5);
\r
93 AddressbookMenu.addItemsToList(this.menuList, menuType, client);
\r