]> git.mxchange.org Git - jcore.git/commitdiff
Don't do this, having chars for database keys, you can directly use the enum name...
authorRoland Haeder <roland@mxchange.org>
Mon, 10 Aug 2015 13:27:42 +0000 (15:27 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 10 Aug 2015 13:27:42 +0000 (15:27 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jcore/contact/BaseContact.java
src/org/mxchange/jcore/contact/Gender.java

index 465289a7abfc4adac2db1af68aa49c62e9b8eb07..d5dc47bbe2fdb2cfe56c0a170342e15f8df167bd 100644 (file)
@@ -280,7 +280,7 @@ public class BaseContact extends BaseFrameworkSystem implements Contact {
                String csvString = String.format(
                                "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"", //NOI18N
                                this.isOwnContact(),
-                               this.getGender().getDatabaseValue(),
+                               this.getGender().name(),
                                this.getSurname(),
                                this.getFamilyName(),
                                this.getCompanyName(),
index 46e7f49108384570f3a2cca4b3b2aa2ffee878fd..598b69777c2cfeb90b6d39bfbaa151528bfa2ad4 100644 (file)
@@ -28,108 +28,19 @@ public enum Gender {
        /**
         * Unknown enum
         */
-       UNKNOWN("U", "BaseContact.gender.unknown.text"),
+       UNKNOWN("BaseContact.gender.unknown.text"),
        /**
         * Male enum
         */
-       MALE("M", "BaseContact.gender.male.text"),
+       MALE("BaseContact.gender.male.text"),
        /**
         * Female enum
         */
-       FEMALE("F", "BaseContact.gender.female.text"),
+       FEMALE("BaseContact.gender.female.text"),
        /**
         * Company enum
         */
-       COMPANY("C", "BaseContact.gender.company.text");
-
-       /**
-        * Cache for valid chars
-        */
-       private static char[] validChars;
-
-       /**
-        * Getter for Gender enum from given character
-        *
-        * @param gender Gender character
-        * @return Gender enum
-        */
-       public static Gender fromChar (final char gender) {
-               Gender g = null;
-               switch (gender) {
-                       case 'U': // Unknown
-                               g = UNKNOWN;
-                               break;
-
-                       case 'M': // Male
-                               g = MALE;
-                               break;
-
-                       case 'F': // Female
-                               g = FEMALE;
-                               break;
-
-                       case 'C': // Company
-                               g = COMPANY;
-                               break;
-
-                       default: // Unsupported
-                               throw new IllegalArgumentException("gender " + gender + " is invalid.");
-               }
-
-               // Return it
-               //* NOISY-DEBUG: */ System.out.println("gender=" + g.getClass().getName());
-               return g;
-       }
-
-       /**
-        * Valid chars
-        *
-        * @return Valid chars
-        */
-       public static char[] validChars () {
-               // Is cache set?
-               if (validChars != null) {
-                       // Return it
-                       return validChars;
-               }
-
-               // Init array
-               char[] valid = new char[3];
-
-               // Get values
-               int i = 0;
-               for (Object value : values()) {
-                       // First cast
-                       Gender gender = (Gender) value;
-
-                       // Debug message
-                       //* NOISY-DEBUG: */ System.out.println("gender=" + gender);
-                       // 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);
-
-                       // Increment index
-                       i++;
-               }
-
-               // Set it here
-               validChars = valid;
-
-               // Return finialized array
-               return valid;
-       }
-
-       /**
-        * Database value
-        */
-       private final String databaseValue;
+       COMPANY("BaseContact.gender.company.text");
 
        /**
         * Output value (for messages)
@@ -139,24 +50,12 @@ public enum Gender {
        /**
         * Constructor
         *
-        * @param databaseValue Value being stored in database
         * @param messageKey Message key for resource file
         */
-       private Gender (final String databaseValue, final String messageKey) {
-               // Set both
-               this.databaseValue = databaseValue;
+       private Gender (final String messageKey) {
                this.messageKey = messageKey;
        }
 
-       /**
-        * Database value
-        *
-        * @return the databaseValue
-        */
-       public String getDatabaseValue () {
-               return this.databaseValue;
-       }
-
        /**
         * Output value (for messages)
         *