*/
package org.mxchange.addressbook.menu.item.console;
+import java.text.MessageFormat;
import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.menu.item.BaseMenuItem;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
* @author Roland Haeder
*/
public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {
- /**
- * Access key
- */
- private char accessKey;
- /**
- * Text to user
- */
- private String text;
+ /**
+ * Access key
+ */
+ private char accessKey;
- /**
- * Constructor for building a console menu with access key and text
- *
- * @param accessKey Access key for this menu entry
- * @param text Text to show to user
- */
- public ConsoleMenuItem (final char accessKey, final String text) {
- this.accessKey = accessKey;
- this.text = text;
- }
+ /**
+ * Text to user
+ */
+ private String text;
- /**
- * Access key
- * @return the accessKey
- */
- @Override
- public final char getAccessKey () {
- return this.accessKey;
- }
+ /**
+ * Constructor for building a console menu with access key and text
+ *
+ * @param accessKey Access key for this menu entry
+ * @param text Text to show to user
+ */
+ public ConsoleMenuItem (final char accessKey, final String text) {
+ this.setAccessKey(accessKey);
+ this.setText(text);
+ }
- /**
- * Text to user
- * @return the text
- */
- @Override
- public String getText () {
- return this.text;
- }
+ /**
+ * Access key
+ *
+ * @return the accessKey
+ */
+ @Override
+ public final char getAccessKey () {
+ return this.accessKey;
+ }
- @Override
- public void show (final Client client) {
- // Call-back client over menu
- client.showEntry(this);
- }
+ /**
+ * Text to user
+ *
+ * @return the text
+ */
+ @Override
+ public String getText () {
+ return this.text;
+ }
- /**
- * Text to user
- * @param text the text to set
- */
- private void setText (String text) {
- this.text = text;
- }
+ @Override
+ public void show (final Client client) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("client={0} - CALLED!", client)); //NOI18N
+
+ // Client must not be null
+ if (client == null) {
+ // Abort here
+ throw new NullPointerException("client is null");
+ }
+
+ // Call-back client over menu
+ client.showEntry(this);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
+ }
+
+ /**
+ * Text to user
+ *
+ * @param text the text to set
+ */
+ private void setText (String text) {
+ this.text = text;
+ }
+
+ /**
+ * Access key
+ *
+ * @param accessKey the accessKey to set
+ */
+ private void setAccessKey (char accessKey) {
+ this.accessKey = accessKey;
+ }
- /**
- * Access key
- * @param accessKey the accessKey to set
- */
- private void setAccessKey (char accessKey) {
- this.accessKey = accessKey;
- }
-
}