]> git.mxchange.org Git - jfinancials-swing.git/blobdiff - Addressbook/src/org/mxchange/addressbook/menu/item/console/ConsoleMenuItem.java
Added a lot trace messages + sanity checks for null references and such things
[jfinancials-swing.git] / Addressbook / src / org / mxchange / addressbook / menu / item / console / ConsoleMenuItem.java
index 82dd838c42348a85b8c05f9492b978ce17dc6afb..8b863cd0c0ab3e484e6091e1863ecf83eed5b5b4 100644 (file)
@@ -16,6 +16,7 @@
  */
 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;
@@ -25,65 +26,82 @@ 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;
-    }
-    
 }