-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.menu.item.console;\r
-\r
-import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.menu.item.BaseMenuItem;\r
-import org.mxchange.addressbook.menu.item.SelectableMenuItem;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder\r
- */\r
-public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {\r
- /**\r
- * Access key\r
- */\r
- private char accessKey;\r
-\r
- /**\r
- * Text to user\r
- */\r
- private String text;\r
-\r
- /**\r
- * Constructor for building a console menu with access key and text\r
- * \r
- * @param accessKey Access key for this menu entry\r
- * @param text Text to show to user\r
- */\r
- public ConsoleMenuItem (final char accessKey, final String text) {\r
- this.accessKey = accessKey;\r
- this.text = text;\r
- }\r
-\r
- /**\r
- * Access key\r
- * @return the accessKey\r
- */\r
- @Override\r
- public char getAccessKey () {\r
- return this.accessKey;\r
- }\r
-\r
- /**\r
- * Access key\r
- * @param accessKey the accessKey to set\r
- */\r
- private void setAccessKey (char accessKey) {\r
- this.accessKey = accessKey;\r
- }\r
-\r
- /**\r
- * Text to user\r
- * @return the text\r
- */\r
- @Override\r
- public String getText () {\r
- return this.text;\r
- }\r
-\r
- /**\r
- * Text to user\r
- * @param text the text to set\r
- */\r
- private void setText (String text) {\r
- this.text = text;\r
- }\r
-\r
- @Override\r
- public void show (final Client client) {\r
- // Call-back client over menu\r
- client.showEntry(this);\r
- }\r
- \r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.menu.item.console;
+
+import java.text.MessageFormat;
+import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.addressbook.menu.item.BaseMenuItem;
+import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {
+
+ /**
+ * Access key
+ */
+ private char accessKey;
+
+ /**
+ * Text to user
+ */
+ private String text;
+
+ /**
+ * Constructor for building a console menu with access key and text
+ * <p>
+ * @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);
+ }
+
+ /**
+ * Access key
+ * <p>
+ * @return the accessKey
+ */
+ @Override
+ public final char getAccessKey () {
+ return this.accessKey;
+ }
+
+ /**
+ * Access key
+ * <p>
+ * @param accessKey the accessKey to set
+ */
+ private void setAccessKey (char accessKey) {
+ this.accessKey = accessKey;
+ }
+
+ /**
+ * Text to user
+ * <p>
+ * @return the text
+ */
+ @Override
+ public String getText () {
+ return this.text;
+ }
+
+ /**
+ * Text to user
+ * <p>
+ * @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 (null == client) {
+ // Abort here
+ throw new NullPointerException("client is null");
+ } else if (!(client instanceof AddressbookClient)) {
+ // Wrong interface
+ throw new IllegalArgumentException("client " + client + " must implement AddressbookClient");
+ }
+
+ // Cast it
+ AddressbookClient c = (AddressbookClient) client;
+
+ // Call-back client over menu
+ c.showEntry(this);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
+ }
+
+}