add "Academic title").
Signed-off-by: Roland Häder <roland@mxchange.org>
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
-import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.contact.title.PersonalTitle;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
void setContactFirstName (final String firstName);
/**
- * Gender of the contact
+ * Getter for personal title
* <p>
- * @return the gender
+ * @return Personal title
*/
- Gender getContactGender ();
+ PersonalTitle getContactPersonalTitle ();
/**
- * Gender of the contact
+ * Setter for personal title
* <p>
- * @param gender the gender to set
+ * @param personalTitle Personal title
*/
- void setContactGender (final Gender gender);
+ void setContactPersonalTitle (final PersonalTitle personalTitle);
/**
* House number
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
-import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.contact.title.PersonalTitle;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jcountry.data.CountryData;
import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
@Column (name = "contact_first_name", length = 100, nullable = false)
private String contactFirstName;
- /**
- * Gender instance
- */
- @Basic (optional = false)
- @Column (name = "contact_gender", nullable = false)
- @Enumerated (EnumType.STRING)
- private Gender contactGender;
-
/**
* House number
*/
@Column (name = "contact_own_contact", nullable = false)
private Boolean contactOwnContact;
+ /**
+ * Contact's personal title (Mr./Mrs.)
+ */
+ @Basic (optional = false)
+ @Column (name = "contact_personal_title", nullable = false)
+ @Enumerated (EnumType.STRING)
+ private PersonalTitle contactPersonalTitle;
+
/**
* Phone number
*/
}
/**
- * Constructor for contactGender and names
+ * Constructor for title and names
* <p>
- * @param contactGender Gender instance
- * @param contactFirstName First name
+ * @param contactTitle Personal title
+ * @param contactFirstName First name
* @param contactFamilyName Family name
*/
- public UserContact (final Gender contactGender, final String contactFirstName, final String contactFamilyName) {
+ public UserContact (final PersonalTitle contactTitle, final String contactFirstName, final String contactFamilyName) {
// Call default constructor
this();
// Set all
- this.contactGender = contactGender;
+ this.contactPersonalTitle = contactTitle;
this.contactFirstName = contactFirstName;
this.contactFamilyName = contactFamilyName;
}
// Copy all:
// - base data
- this.setContactGender(contact.getContactGender());
+ this.setContactPersonalTitle(contact.getContactPersonalTitle());
this.setContactTitle(contact.getContactTitle());
this.setContactFirstName(contact.getContactFirstName());
this.setContactFamilyName(contact.getContactFamilyName());
return false;
} else if (!Objects.equals(this.getContactCountry(), other.getContactCountry())) {
return false;
- } else if (this.getContactGender() != other.getContactGender()) {
+ } else if (this.getContactPersonalTitle() != other.getContactPersonalTitle()) {
return false;
} else if (!Objects.equals(this.getContactHouseNumber(), other.getContactHouseNumber())) {
return false;
this.contactFirstName = contactFirstName;
}
- @Override
- public Gender getContactGender () {
- return this.contactGender;
- }
-
- @Override
- public void setContactGender (final Gender contactGender) {
- this.contactGender = contactGender;
- }
-
@Override
public Short getContactHouseNumber () {
return this.contactHouseNumber;
this.contactOwnContact = contactOwnContact;
}
+ @Override
+ public PersonalTitle getContactPersonalTitle () {
+ return this.contactPersonalTitle;
+ }
+
+ @Override
+ public void setContactPersonalTitle (final PersonalTitle contactPersonalTitle) {
+ this.contactPersonalTitle = contactPersonalTitle;
+ }
+
@Override
public String getContactStreet () {
return this.contactStreet;
hash = 29 * hash + Objects.hashCode(this.getContactEmailAddress());
hash = 29 * hash + Objects.hashCode(this.getContactFamilyName());
hash = 29 * hash + Objects.hashCode(this.getContactFirstName());
- hash = 29 * hash + Objects.hashCode(this.getContactGender());
+ hash = 29 * hash + Objects.hashCode(this.getContactPersonalTitle());
hash = 29 * hash + Objects.hashCode(this.getContactHouseNumber());
hash = 29 * hash + Objects.hashCode(this.getContactHouseNumberExtension());
hash = 29 * hash + Objects.hashCode(this.getContactId());
package org.mxchange.jcontacts.contact.gender;
import java.io.Serializable;
-import java.text.MessageFormat;
/**
- * Gender enum
+ * An enumeration for genders, sure more need to be added here. If you need
+ * titles instead, please use the proper enumeration then.
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
public enum Gender implements Serializable {
/**
- * Male enum
+ * Male gender
*/
MALE('M', "GENDER_MALE"), //NOI18N
/**
- * Female enum
+ * Female gender
*/
FEMALE('F', "GENDER_FEMALE"); //NOI18N
- /**
- * Cache for valid chars
- */
- private static char[] validChars;
-
/**
* Access key being entered by ConsoleClient
*/
*/
private final String messageKey;
- /**
- * Getter for Gender enum from given character
- * <p>
- * @param c Gender character
- * <p>
- * @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)
- * <p>
- * @return Valid chars
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- 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
* <p>
}
/**
- * Acces key (console client mostly)
+ * Access key (console client mostly)
* <p>
* @return the accessChar
*/
package org.mxchange.jcontacts.contact.gender;
import java.io.Serializable;
+import java.text.MessageFormat;
import java.util.LinkedList;
import java.util.List;
private static final long serialVersionUID = 185_683_479_107L;
/**
- * All selectable genders (not UNKNOWN)
+ * Cache for valid chars
+ */
+ private static char[] validChars;
+
+ /**
+ * All available genders as a list
* <p>
* @return Selectable genders (not UNKNOWN)
*/
- public static List<Gender> selectableGenders () {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("GenderUtils.selectableGenders: CALLED!"); //NOI18N
-
+ public static List<Gender> allGendersAsList () {
// Init list
List<Gender> list = new LinkedList<>();
// Walk through all genders
for (final Gender gender : Gender.values()) {
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("GenderUtils.selectableGenders: gender={0}", gender)); //NOI18N
-
// Add it and check if it has been added
list.add(gender);
}
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("GenderUtils.selectableGenders: list.size()={0} - EXIT!", list.size())); //NOI18N
-
// Return it
return list;
}
/**
- * Private contructor as this is an utility class
+ * Getter for Gender enumeration from given character
+ * <p>
+ * @param c Gender character
+ <p>
+ * @return Gender enumeration
+ */
+ public static Gender fromChar (final char c) {
+ // Init variable
+ Gender found = null;
+
+ // Loop through all
+ for (final Gender gender : Gender.values()) {
+ // Does the char match?
+ if (c == gender.getAccessChar()) {
+ // Found it
+ found = gender;
+ break;
+ }
+ }
+
+ // Still null?
+ if (null == found) {
+ // Didn't found a valid one
+ throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c)); //NOI18N
+ }
+
+ // Return it
+ return found;
+ }
+
+ /**
+ * Valid chars (mostly for console client)
+ * <p>
+ * @return Valid chars
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public static char[] validChars () {
+ // Is cache set?
+ if (validChars != null) {
+ // Return it
+ return validChars;
+ }
+
+ // Init array, only 2 are valid.
+ char[] valid = new char[2];
+
+ // Get values
+ int i = 0;
+ for (final Gender gender : Gender.values()) {
+ // 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;
+ }
+
+ /**
+ * Private constructor as this is an utility class
*/
private GenderUtils () {
}
--- /dev/null
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * 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.jcontacts.contact.title;
+
+import java.io.Serializable;
+
+/**
+ * An enumeration for personal titles. If you need the gender instead, please
+ * use the other enumeration instead.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public enum PersonalTitle implements Serializable {
+
+ /**
+ * Title "Mr."
+ */
+ MR('M', "PERSONAL_TITLE_MR"), //NOI18N
+
+ /**
+ * Title "Mrs."
+ */
+ MRS('F', "PERSONAL_TITLE_MRS"); //NOI18N
+
+ /**
+ * Access key being entered by ConsoleClient
+ */
+ private final char accessChar;
+
+ /**
+ * Output value (for messages)
+ */
+ private final String messageKey;
+
+ /**
+ * Constructor
+ * <p>
+ * @param accessChar Value being entered by ConsoleClient
+ * @param messageKey Message key for resource file
+ */
+ private PersonalTitle (final char accessChar, final String messageKey) {
+ // Set both
+ this.accessChar = accessChar;
+ this.messageKey = messageKey;
+ }
+
+ /**
+ * Access key (console client mostly)
+ * <p>
+ * @return the accessChar
+ */
+ public char getAccessChar () {
+ return this.accessChar;
+ }
+
+ /**
+ * Output value (for messages)
+ * <p>
+ * @return the messageKey
+ */
+ public String getMessageKey () {
+ return this.messageKey;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * 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.jcontacts.contact.title;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Title utilities class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class TitleUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 185_683_479_107L;
+
+ /**
+ * Cache for valid chars
+ */
+ private static char[] validChars;
+
+ /**
+ * All available personal titles as a list
+ * <p>
+ * @return Selectable personal titles
+ */
+ public static List<PersonalTitle> allPersonalTitlesAsList () {
+ // Init list
+ List<PersonalTitle> list = new LinkedList<>();
+
+ // Walk through all genders
+ for (final PersonalTitle title : PersonalTitle.values()) {
+ // Add it and check if it has been added
+ list.add(title);
+ }
+
+ // Return it
+ return list;
+ }
+
+ /**
+ * Getter for personal title enumeration from given character
+ * <p>
+ * @param c PersonalTitle character
+ * <p>
+ * @return PersonalTitle enumeration
+ */
+ public static PersonalTitle getPersonalTitleFromChar (final char c) {
+ // Init variable
+ PersonalTitle found = null;
+
+ // Loop through all
+ for (final PersonalTitle title : PersonalTitle.values()) {
+ // Does the char match?
+ if (c == title.getAccessChar()) {
+ // Found it
+ found = title;
+ break;
+ }
+ }
+
+ // Still null?
+ if (null == found) {
+ // Didn't found a valid one
+ throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c)); //NOI18N
+ }
+
+ // Return it
+ return found;
+ }
+
+ /**
+ * Valid chars (mostly for console client)
+ * <p>
+ * @return Valid chars
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public static char[] validChars () {
+ // Is cache set?
+ if (validChars != null) {
+ // Return it
+ return validChars;
+ }
+
+ // Init array, only 2 are valid.
+ char[] valid = new char[2];
+
+ // Get values
+ int i = 0;
+ for (final PersonalTitle title : PersonalTitle.values()) {
+ // Get access key as this is also the access
+ valid[i] = title.getAccessChar();
+
+ // Increment index
+ i++;
+ }
+
+ // Set it here
+ validChars = valid;
+
+ // Return finialized array
+ return valid;
+ }
+
+ /**
+ * Private constructor as this is an utility class
+ */
+ private TitleUtils () {
+ }
+
+}
(Objects.equals(contact.getContactEmailAddress(), other.getContactEmailAddress())) &&
(Objects.equals(contact.getContactFamilyName(), other.getContactFamilyName())) &&
(Objects.equals(contact.getContactFirstName(), other.getContactFirstName())) &&
- (Objects.equals(contact.getContactGender(), other.getContactGender())) &&
+ (Objects.equals(contact.getContactPersonalTitle(), other.getContactPersonalTitle())) &&
(Objects.equals(contact.getContactHouseNumber(), other.getContactHouseNumber())) &&
(Objects.equals(contact.getContactStreet(), other.getContactStreet())) &&
(Objects.equals(contact.getContactTitle(), other.getContactTitle())) &&
* @param contact Contact that is already added
*/
public ContactAlreadyAddedException (final Contact contact) {
- super(MessageFormat.format("Contact with gender={0}, firstName={1} and familyName={2} already added.", contact.getContactGender(), contact.getContactFirstName(), contact.getContactFamilyName())); //NOI18N
+ super(MessageFormat.format("Contact with gender={0}, firstName={1} and familyName={2} already added.", contact.getContactPersonalTitle(), contact.getContactFirstName(), contact.getContactFamilyName())); //NOI18N
}
/**