*/
private Manageable manager;
- /**
- * Session id assigned with this basket, or any other unique identifier
- */
- private String sessionId;
-
/**
* Name of used database table, handled over to backend
*/
this.client = client;
}
- /**
- * Getter for session id
- *
- * @return Session id
- */
- @Override
- public final String getSessionId () {
- return this.sessionId;
- }
-
- /**
- * Setter for session id
- *
- * @param sessionId Session id
- */
- @Override
- public final void setSessionId (final String sessionId) {
- this.sessionId = sessionId;
- }
-
/**
* Name of used database table, handled over to backend
*
this.getLogger().trace("CALLED!"); //NOI18N
// Is the bundle set?
- if (this.isBundledInitialized()) {
+ if (isBundledInitialized()) {
// Is already set
throw new IllegalStateException("called twice"); //NOI18N
}
*
* @return Whether the bundle has been initialized
*/
- protected boolean isBundledInitialized () {
+ protected static boolean isBundledInitialized () {
// Check it
return (bundle instanceof ResourceBundle);
}
*/
public Application getApplication ();
- /**
- * Session id
- * @return the sessionId
- */
- public String getSessionId ();
-
- /**
- * Session id
- * @param sessionId the sessionId to set
- */
- public void setSessionId (final String sessionId);
-
/**
* Getter for human-readable string from given key
*
import java.util.Objects;
import org.mxchange.jcore.BaseFrameworkSystem;
import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.contact.gender.Gender;
/**
* A general contact class which should only be extended.
import java.util.Iterator;
import java.util.Map;
import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.contact.gender.Gender;
import org.mxchange.jcore.database.storage.Storable;
/**
+++ /dev/null
-/*
- * 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.jcore.contact;
-
-import java.text.MessageFormat;
-
-/**
- * Gender enum
- *
- * @author Roland Haeder
- */
-public enum Gender {
- /**
- * Unknown enum
- */
- UNKNOWN('U', "BaseContact.gender.unknown.text"), //NOI18N
-
- /**
- * Male enum
- */
- MALE('M', "BaseContact.gender.male.text"), //NOI18N
-
- /**
- * Female enum
- */
- FEMALE('F', "BaseContact.gender.female.text"), //NOI18N
-
- /**
- * Company enum
- */
- COMPANY('C', "BaseContact.gender.company.text"); //NOI18N
-
- /**
- * Cache for valid chars
- */
- private static char[] validChars;
-
- /**
- * Access key being entered by ConsoleClient
- */
- private final char accessChar;
-
- /**
- * Output value (for messages)
- */
- private final String messageKey;
-
- /**
- * Getter for Gender enum from given character
- *
- * @param c Gender character
- * @return Gender enum
- */
- public static Gender fromChar (final char c) {
- // Init variable
- Gender g = null;
-
- // Loop through all
- for (final Gender gender : Gender.values()) {
- // Does the char match?
- if (c == gender.getAccessChar()) {
- // Found it
- g = gender;
- break;
- }
- }
-
- // Still null?
- if (null == g) {
- // Didn't found a valid one
- throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c)); //NOI18N
- }
-
- // 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, only 3 are valid as 'U' is UNKNOWN and is not valid.
- char[] valid = new char[3];
-
- // Get values
- int i = 0;
- for (Gender gender : values()) {
- // 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 access key as this is also the access
- valid[i] = gender.getAccessChar();
-
- // Increment index
- i++;
- }
-
- // Set it here
- validChars = valid;
-
- // Return finialized array
- return valid;
- }
-
- /**
- * Constructor
- *
- * @param accessChar Value being entered by ConsoleClient
- * @param messageKey Message key for resource file
- */
- private Gender (final char accessChar, final String messageKey) {
- // Set both
- this.accessChar = accessChar;
- this.messageKey = messageKey;
- }
-
- /**
- * Acces key (console client mostly)
- *
- * @return the accessChar
- */
- public char getAccessChar () {
- return this.accessChar;
- }
-
- /**
- * Output value (for messages)
- *
- * @return the messageKey
- */
- public String getMessageKey () {
- return this.messageKey;
- }
-}
--- /dev/null
+/*
+ * 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.jcore.contact.gender;
+
+import java.text.MessageFormat;
+
+/**
+ * Gender enum
+ *
+ * @author Roland Haeder
+ */
+public enum Gender {
+ /**
+ * Unknown enum
+ */
+ UNKNOWN('U', "BaseContact.gender.unknown.text"), //NOI18N
+
+ /**
+ * Male enum
+ */
+ MALE('M', "BaseContact.gender.male.text"), //NOI18N
+
+ /**
+ * Female enum
+ */
+ FEMALE('F', "BaseContact.gender.female.text"), //NOI18N
+
+ /**
+ * Company enum
+ */
+ COMPANY('C', "BaseContact.gender.company.text"); //NOI18N
+
+ /**
+ * Cache for valid chars
+ */
+ private static char[] validChars;
+
+ /**
+ * Access key being entered by ConsoleClient
+ */
+ private final char accessChar;
+
+ /**
+ * Output value (for messages)
+ */
+ private final String messageKey;
+
+ /**
+ * Getter for Gender enum from given character
+ *
+ * @param c Gender character
+ * @return Gender enum
+ */
+ public static Gender fromChar (final char c) {
+ // Init variable
+ Gender g = null;
+
+ // Loop through all
+ for (final Gender gender : GenderUtils.selectableGenders()) {
+ // Does the char match?
+ if (c == gender.getAccessChar()) {
+ // Found it
+ g = gender;
+ break;
+ }
+ }
+
+ // Still null?
+ if (null == g) {
+ // Didn't found a valid one
+ throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c)); //NOI18N
+ }
+
+ // Return it
+ //* NOISY-DEBUG: */ System.out.println("gender=" + g.getClass().getName());
+ return g;
+ }
+
+ /**
+ * Valid chars (mostly for console client)
+ *
+ * @return Valid chars
+ */
+ public static char[] validChars () {
+ // Is cache set?
+ if (validChars != null) {
+ // Return it
+ return validChars;
+ }
+
+ // Init array, only 3 are valid as 'U' is UNKNOWN and is not valid.
+ char[] valid = new char[3];
+
+ // Get values
+ int i = 0;
+ for (final Gender gender : GenderUtils.selectableGenders()) {
+ // Debug message
+ //* NOISY-DEBUG: */ System.out.println("gender=" + gender);
+
+ // Debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("gender={0} - adding at pos {1} ...", gender, i));
+
+ // Get access key as this is also the access
+ valid[i] = gender.getAccessChar();
+
+ // Increment index
+ i++;
+ }
+
+ // Set it here
+ validChars = valid;
+
+ // Return finialized array
+ return valid;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param accessChar Value being entered by ConsoleClient
+ * @param messageKey Message key for resource file
+ */
+ private Gender (final char accessChar, final String messageKey) {
+ // Set both
+ this.accessChar = accessChar;
+ this.messageKey = messageKey;
+ }
+
+ /**
+ * Acces key (console client mostly)
+ *
+ * @return the accessChar
+ */
+ public char getAccessChar () {
+ return this.accessChar;
+ }
+
+ /**
+ * Output value (for messages)
+ *
+ * @return the messageKey
+ */
+ public String getMessageKey () {
+ return this.messageKey;
+ }
+}
--- /dev/null
+/*
+ * 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.jcore.contact.gender;
+
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+import org.mxchange.jcore.BaseFrameworkSystem;
+
+/**
+ * Gender utils class
+ *
+ * @author Roland Haeder
+ */
+public final class GenderUtils extends BaseFrameworkSystem {
+ /**
+ * Private contructor as this is an utility class
+ */
+ private GenderUtils () {
+ }
+
+ /**
+ * All selectable genders (not UNKNOWN)
+ *
+ * @return Selectable genders (not UNKNOWN)
+ */
+ public static List<Gender> selectableGenders () {
+ // Trace message
+ new GenderUtils().getLogger().trace("CALLED!"); //NOI18N
+
+ // Init list
+ List<Gender> list = new LinkedList<>();
+
+ // Walk through all genders
+ for (final Gender gender : Gender.values()) {
+ // Debug log
+ new GenderUtils().getLogger().debug(MessageFormat.format("gender={0}", gender)); //NOI18N
+
+ // Is it not UNKNOWN
+ if (!gender.equals(Gender.UNKNOWN)) {
+ // Add it
+ boolean added = list.add(gender);
+
+ // Has it been added?
+ assert(added) : MessageFormat.format("gender {0} not added.", gender); //NOI18N
+ }
+ }
+
+ // Trace message
+ new GenderUtils().getLogger().trace(MessageFormat.format("list={0} - EXIT!", list)); //NOI18N
+
+ // Return it
+ return list;
+ }
+}