]> git.mxchange.org Git - addressbook-lib.git/blob - src/org/mxchange/addressbook/menu/item/console/ConsoleMenuItem.java
Project relocated (a bit better now?) + continued with Swing client
[addressbook-lib.git] / src / org / mxchange / addressbook / menu / item / console / ConsoleMenuItem.java
1 /*\r
2  * Copyright (C) 2015 Roland Haeder\r
3  *\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
8  *\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
13  *\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
16  */\r
17 package org.mxchange.addressbook.menu.item.console;\r
18 \r
19 import org.mxchange.addressbook.client.Client;\r
20 import org.mxchange.addressbook.menu.item.BaseMenuItem;\r
21 import org.mxchange.addressbook.menu.item.SelectableMenuItem;\r
22 \r
23 /**\r
24  *\r
25  * @author Roland Haeder\r
26  */\r
27 public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {\r
28     /**\r
29      * Access key\r
30      */\r
31     private char accessKey;\r
32 \r
33     /**\r
34      * Text to user\r
35      */\r
36     private String text;\r
37 \r
38     /**\r
39      * Constructor for building a console menu with access key and text\r
40      * \r
41      * @param accessKey Access key for this menu entry\r
42      * @param text Text to show to user\r
43      */\r
44     public ConsoleMenuItem (final char accessKey, final String text) {\r
45         this.accessKey = accessKey;\r
46         this.text = text;\r
47     }\r
48 \r
49     /**\r
50      * Access key\r
51      * @return the accessKey\r
52      */\r
53     @Override\r
54     public char getAccessKey () {\r
55         return this.accessKey;\r
56     }\r
57 \r
58     /**\r
59      * Access key\r
60      * @param accessKey the accessKey to set\r
61      */\r
62     private void setAccessKey (char accessKey) {\r
63         this.accessKey = accessKey;\r
64     }\r
65 \r
66     /**\r
67      * Text to user\r
68      * @return the text\r
69      */\r
70     @Override\r
71     public String getText () {\r
72         return this.text;\r
73     }\r
74 \r
75     /**\r
76      * Text to user\r
77      * @param text the text to set\r
78      */\r
79     private void setText (String text) {\r
80         this.text = text;\r
81     }\r
82 \r
83     @Override\r
84     public void show (final Client client) {\r
85         // Call-back client over menu\r
86         client.showEntry(this);\r
87     }\r
88     \r
89 }\r