]> git.mxchange.org Git - jfinancials-lib.git/blob - Addressbook/src/org/mxchange/addressbook/menu/BaseMenu.java
Global commit: Changed spaces to tabs, because all Java files have tabs for indenting
[jfinancials-lib.git] / Addressbook / src / org / mxchange / addressbook / menu / BaseMenu.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.addressbook.menu;
18
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22 import org.mxchange.addressbook.BaseFrameworkSystem;
23 import org.mxchange.addressbook.client.Client;
24 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
25
26 /**
27  *
28  * @author Roland Haeder
29  */
30 public class BaseMenu extends BaseFrameworkSystem {
31
32         /**
33          * Menu list
34          */
35         private List<SelectableMenuItem> menuList;
36
37         /**
38          * No instance from this object
39          */
40         protected BaseMenu () {
41                 super();
42         }
43
44         /**
45          * Size of menu items
46          *
47          * @return Count of menu items
48          */
49         public int getMenuItemsCount () {
50                 return this.menuList.size();
51         }
52
53         /**
54          * "Getter" for an iterator of this menu's items
55          *
56          * @return An iterator of all menu items
57          */
58         public Iterator<SelectableMenuItem> getMenuItemsIterator () {
59                 return this.menuList.iterator();
60         }
61
62         /**
63          * Shows this menu
64          *
65          * @param client Client instance to call back
66          */
67         public void show (final Client client) {
68                 // Get values
69                 Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
70
71                 // Debug message
72                 this.getLogger().debug("Showing menu with '" + this.menuList.size() + "' entries.");
73
74                 // Output all menus
75                 while (iterator.hasNext()) {
76                         // Get item
77                         SelectableMenuItem item = iterator.next();
78
79                         // Show this item
80                         item.show(client);
81                 }
82         }
83
84         /**
85          * Getter for menu list
86          *
87          * @return      menuList List of menu entries
88          */
89         protected final List<SelectableMenuItem> getMenuList () {
90                 return this.menuList;
91         }
92
93         /**
94          * Initializes menu
95          *
96          * @param menuType      Menu type to initialize
97          * @param client CLient to call back
98          */
99         protected void initMenu (final String menuType, final Client client) {
100                 // Init menu list
101                 this.menuList = new ArrayList<>(5);
102         }
103 }