]> git.mxchange.org Git - addressbook-swing.git/blobdiff - Addressbook/src/org/mxchange/addressbook/contact/Gender.java
Added a lot trace messages + sanity checks for null references and such things
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / contact / Gender.java
index 96bce2c17f9cfda41de47915ae14358e53f11ff8..cdfab047a3dfb96a10e12cdc51856e1c55364439 100644 (file)
  */
 package org.mxchange.addressbook.contact;
 
+import org.mxchange.addressbook.application.AddressbookApplication;
+
 /**
  * Gender enum
+ *
  * @author Roland Haeder
  */
 public enum Gender {
+
        /**
         * Unknown enum
         */
        UNKNOWN("U", "BaseContact.gender.unknown.text"),
-
        /**
         * Male enum
         */
        MALE("M", "BaseContact.gender.male.text"),
-
        /**
         * Female enum
         */
        FEMALE("F", "BaseContact.gender.female.text"),
-
        /**
         * Company enum
         */
@@ -76,12 +77,13 @@ public enum Gender {
                }
 
                // Return it
+               //* NOISY-DEBUG: */ System.out.println("gender=" + g.getClass().getName());
                return g;
        }
 
        /**
         * Valid chars
-        * 
+        *
         * @return Valid chars
         */
        public static char[] validChars () {
@@ -102,16 +104,14 @@ public enum Gender {
 
                        // Debug message
                        //* NOISY-DEBUG: */ System.out.println("gender=" + gender);
-
-                       // Is it "U"?
-                       if (gender.getDatabaseValue().equals("U")) {
+                       // Is it UNKNOWN?
+                       if (gender.equals(Gender.UNKNOWN)) {
                                // Skip this
                                continue;
                        }
 
                        // Debug message
                        //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("gender={0} - adding at pos {1} ...", gender, i));
-
                        // Get database value as this is also the access
                        valid[i] = gender.getDatabaseValue().charAt(0);
 
@@ -138,7 +138,7 @@ public enum Gender {
 
        /**
         * Constructor
-        * 
+        *
         * @param databaseValue Value being stored in database
         * @param messageKey Message key for resource file
         */
@@ -150,7 +150,7 @@ public enum Gender {
 
        /**
         * Database value
-        * 
+        *
         * @return the databaseValue
         */
        protected String getDatabaseValue () {
@@ -159,10 +159,21 @@ public enum Gender {
 
        /**
         * Output value (for messages)
-        * 
+        *
         * @return the messageKey
         */
        protected String getMessageKey () {
                return this.messageKey;
        }
+
+       /**
+        * Overwritten to return human-readable strings
+        *
+        * @return Human-readable strings
+        */
+       @Override
+       public String toString () {
+               // Get key from bundle and return it
+               return AddressbookApplication.getInstance().getMessageStringFromKey(this.getMessageKey());
+       }
 }