]> git.mxchange.org Git - jcontacts-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 10 Sep 2017 14:42:46 +0000 (16:42 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 10 Sep 2017 14:42:46 +0000 (16:42 +0200)
- moved model-related classes (entities, of course) to own 'model' package

Signed-off-by: Roland Häder <roland@mxchange.org>
35 files changed:
src/org/mxchange/jcontacts/contact/Contact.java [deleted file]
src/org/mxchange/jcontacts/contact/ContactUtils.java [deleted file]
src/org/mxchange/jcontacts/contact/UserContact.java [deleted file]
src/org/mxchange/jcontacts/contact/gender/Gender.java [deleted file]
src/org/mxchange/jcontacts/contact/gender/GenderUtils.java [deleted file]
src/org/mxchange/jcontacts/contact/title/PersonalTitle.java [deleted file]
src/org/mxchange/jcontacts/contact/title/TitleUtils.java [deleted file]
src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java
src/org/mxchange/jcontacts/events/contact/add/ObservableAdminAddedContactEvent.java
src/org/mxchange/jcontacts/events/contact/created/CreatedContactEvent.java
src/org/mxchange/jcontacts/events/contact/created/ObservableCreatedContactEvent.java
src/org/mxchange/jcontacts/events/contact/deleted/AdminDeletedContactEvent.java
src/org/mxchange/jcontacts/events/contact/deleted/ObservableAdminDeletedContactEvent.java
src/org/mxchange/jcontacts/events/contact/update/AdminUpdatedContactEvent.java
src/org/mxchange/jcontacts/events/contact/update/ObservableAdminUpdatedContactEvent.java
src/org/mxchange/jcontacts/events/fax/linked/AdminLinkedFaxNumberEvent.java
src/org/mxchange/jcontacts/events/fax/linked/ObservableAdminLinkedFaxNumberEvent.java
src/org/mxchange/jcontacts/events/fax/unlinked/AdminUnlinkedFaxNumberEvent.java
src/org/mxchange/jcontacts/events/fax/unlinked/ObservableAdminUnlinkedFaxNumberEvent.java
src/org/mxchange/jcontacts/events/landline/linked/AdminLinkedLandLineNumberEvent.java
src/org/mxchange/jcontacts/events/landline/linked/ObservableAdminLinkedLandLineNumberEvent.java
src/org/mxchange/jcontacts/events/landline/unlinked/AdminUnlinkedLandLineNumberEvent.java
src/org/mxchange/jcontacts/events/landline/unlinked/ObservableAdminUnlinkedLandLineNumberEvent.java
src/org/mxchange/jcontacts/events/mobile/linked/AdminLinkedMobileNumberEvent.java
src/org/mxchange/jcontacts/events/mobile/linked/ObservableAdminLinkedMobileNumberEvent.java
src/org/mxchange/jcontacts/events/mobile/unlinked/AdminUnlinkedMobileNumberEvent.java
src/org/mxchange/jcontacts/events/mobile/unlinked/ObservableAdminUnlinkedMobileNumberEvent.java
src/org/mxchange/jcontacts/exceptions/ContactAlreadyAddedException.java
src/org/mxchange/jcontacts/model/contact/Contact.java [new file with mode: 0644]
src/org/mxchange/jcontacts/model/contact/ContactUtils.java [new file with mode: 0644]
src/org/mxchange/jcontacts/model/contact/UserContact.java [new file with mode: 0644]
src/org/mxchange/jcontacts/model/contact/gender/Gender.java [new file with mode: 0644]
src/org/mxchange/jcontacts/model/contact/gender/GenderUtils.java [new file with mode: 0644]
src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java [new file with mode: 0644]
src/org/mxchange/jcontacts/model/contact/title/TitleUtils.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jcontacts/contact/Contact.java b/src/org/mxchange/jcontacts/contact/Contact.java
deleted file mode 100644 (file)
index 89e4113..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * 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;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-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;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-
-/**
- * A general contact POJI
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface Contact extends Serializable {
-
-       /**
-        * Birth day
-        * <p>
-        * @return the birthday
-        */
-       Date getContactBirthday ();
-
-       /**
-        * Birth day
-        * <p>
-        * @param birthday the birthday to set
-        */
-       void setContactBirthday (final Date birthday);
-
-       /**
-        * Getter for mobile number
-        * <p>
-        * @return Mobile number
-        */
-       DialableMobileNumber getContactMobileNumber ();
-
-       /**
-        * Setter for mobile number
-        * <p>
-        * @param mobileNumber Mobile number
-        */
-       void setContactMobileNumber (final DialableMobileNumber mobileNumber);
-
-       /**
-        * City
-        * <p>
-        * @return the city
-        */
-       String getContactCity ();
-
-       /**
-        * City
-        * <p>
-        * @param city the city to set
-        */
-       void setContactCity (final String city);
-
-       /**
-        * Comments
-        * <p>
-        * @return the comment
-        */
-       String getContactComment ();
-
-       /**
-        * Comments
-        * <p>
-        * @param comment the comment to set
-        */
-       void setContactComment (final String comment);
-
-       /**
-        * Id number
-        * <p>
-        * @return the contactId
-        */
-       Long getContactId ();
-
-       /**
-        * Id number
-        * <p>
-        * @param id the contactId to set
-        */
-       void setContactId (final Long id);
-
-       /**
-        * Country code
-        * <p>
-        * @return the countryCode
-        */
-       Country getContactCountry ();
-
-       /**
-        * Country code
-        * <p>
-        * @param contactCountry the countryCode to set
-        */
-       void setContactCountry (final Country contactCountry);
-
-       /**
-        * Getter for "created" timestamp
-        * <p>
-        * @return "created" timestamp
-        */
-       Calendar getContactCreated ();
-
-       /**
-        * Setter for "created" timestamp
-        * <p>
-        * @param created "created" timestamp
-        */
-       void setContactCreated (final Calendar created);
-
-       /**
-        * Email address
-        * <p>
-        * @return the emailAddress
-        */
-       String getContactEmailAddress ();
-
-       /**
-        * Email address
-        * <p>
-        * @param emailAddress the emailAddress to set
-        */
-       void setContactEmailAddress (final String emailAddress);
-
-       /**
-        * Family name
-        * <p>
-        * @return the familyName
-        */
-       String getContactFamilyName ();
-
-       /**
-        * Family name
-        * <p>
-        * @param familyName the familyName to set
-        */
-       void setContactFamilyName (final String familyName);
-
-       /**
-        * Fax number
-        * <p>
-        * @return the faxNumber
-        */
-       DialableFaxNumber getContactFaxNumber ();
-
-       /**
-        * Fax number
-        * <p>
-        * @param faxNumber the faxNumber to set
-        */
-       void setContactFaxNumber (final DialableFaxNumber faxNumber);
-
-       /**
-        * First name
-        * <p>
-        * @return the first name
-        */
-       String getContactFirstName ();
-
-       /**
-        * First name
-        * <p>
-        * @param firstName the first name to set
-        */
-       void setContactFirstName (final String firstName);
-
-       /**
-        * Getter for personal title
-        * <p>
-        * @return Personal title
-        */
-       PersonalTitle getContactPersonalTitle ();
-
-       /**
-        * Setter for personal title
-        * <p>
-        * @param personalTitle Personal title
-        */
-       void setContactPersonalTitle (final PersonalTitle personalTitle);
-
-       /**
-        * House number
-        * <p>
-        * @return the houseNumber
-        */
-       Short getContactHouseNumber ();
-
-       /**
-        * House number
-        * <p>
-        * @param houseNumber the houseNumber to set
-        */
-       void setContactHouseNumber (final Short houseNumber);
-
-       /**
-        * Getter for house number extension, example: 123a 'a' is then the
-        * extension and 123 is the house number.
-        * <p>
-        * @return House number extension
-        */
-       String getContactHouseNumberExtension ();
-
-       /**
-        * Setter for house number extension
-        * <p>
-        * @param contactHouseNumberExtension House number extension
-        */
-       void setContactHouseNumberExtension (final String contactHouseNumberExtension);
-
-       /**
-        * Setter for own contact
-        * <p>
-        * @param ownContact Own contact
-        */
-       void setContactOwnContact (final Boolean ownContact);
-
-       /**
-        * Getter for phone number
-        * <p>
-        * @return Phone number
-        */
-       DialableLandLineNumber getContactLandLineNumber ();
-
-       /**
-        * Setter for phone number
-        * <p>
-        * @param phoneNumber Phone number
-        */
-       void setContactLandLineNumber (final DialableLandLineNumber phoneNumber);
-
-       /**
-        * Street
-        * <p>
-        * @return the street
-        */
-       String getContactStreet ();
-
-       /**
-        * Street
-        * <p>
-        * @param street the street to set
-        */
-       void setContactStreet (final String street);
-
-       /**
-        * Getter for contact's title
-        * <p>
-        * @return Contact's title
-        */
-       String getContactTitle ();
-
-       /**
-        * Setter for contact's title
-        * <p>
-        * @param contactTitle Contact's title
-        */
-       void setContactTitle (final String contactTitle);
-
-       /**
-        * Getter for "updated" timestamp
-        * <p>
-        * @return "updated" timestamp
-        */
-       Calendar getContactUpdated ();
-
-       /**
-        * Getter for "updated" timestamp
-        * <p>
-        * @param updated "updated" timestamp
-        */
-       void setContactUpdated (final Calendar updated);
-
-       /**
-        * ZIP code
-        * <p>
-        * @return the zipCode
-        */
-       Integer getContactZipCode ();
-
-       /**
-        * ZIP code
-        * <p>
-        * @param zipCode the zipCode to set
-        */
-       void setContactZipCode (final Integer zipCode);
-
-       /**
-        * Checks whether the contact is user's own data
-        * <p>
-        * @return Own data?
-        */
-       Boolean isOwnContact ();
-
-       /**
-        * Check if contacts are same or throw an exception
-        * <p>
-        * @param object Other possible contact class
-        * <p>
-        * @return Whether both contacts are same
-        */
-       @Override
-       boolean equals (final Object object);
-
-       @Override
-       int hashCode ();
-
-}
diff --git a/src/org/mxchange/jcontacts/contact/ContactUtils.java b/src/org/mxchange/jcontacts/contact/ContactUtils.java
deleted file mode 100644 (file)
index 7cc6f12..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * 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;
-
-import java.io.Serializable;
-import java.util.Objects;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-
-/**
- * Utilities for contacts
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class ContactUtils implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 26_785_734_719_670L;
-
-       /**
-        * Copies all attributes from other contact object to this
-        * <p>
-        * @param sourceContact Source instance
-        * @param targetContact Target instance
-        */
-       public static void copyAll (final Contact sourceContact, final Contact targetContact) {
-               // Contact should be valid
-               if (null == sourceContact) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceContact is null"); //NOI18N
-               } else if (null == targetContact) {
-                       // Throw NPE
-                       throw new NullPointerException("targetContact is null"); //NOI18N
-               }
-
-               // Copy all:
-               // - base data
-               targetContact.setContactPersonalTitle(sourceContact.getContactPersonalTitle());
-               targetContact.setContactTitle(sourceContact.getContactTitle());
-               targetContact.setContactFirstName(sourceContact.getContactFirstName());
-               targetContact.setContactFamilyName(sourceContact.getContactFamilyName());
-               targetContact.setContactStreet(sourceContact.getContactStreet());
-               targetContact.setContactHouseNumber(sourceContact.getContactHouseNumber());
-               targetContact.setContactHouseNumberExtension(sourceContact.getContactHouseNumberExtension());
-               targetContact.setContactZipCode(sourceContact.getContactZipCode());
-               targetContact.setContactCity(sourceContact.getContactCity());
-               targetContact.setContactCountry(sourceContact.getContactCountry());
-
-               // - phone, fax, email
-               targetContact.setContactLandLineNumber(sourceContact.getContactLandLineNumber());
-               targetContact.setContactFaxNumber(sourceContact.getContactFaxNumber());
-               targetContact.setContactMobileNumber(sourceContact.getContactMobileNumber());
-
-               // - other data
-               targetContact.setContactBirthday(sourceContact.getContactBirthday());
-               targetContact.setContactComment(sourceContact.getContactComment());
-               targetContact.setContactCreated(sourceContact.getContactCreated());
-               targetContact.setContactUpdated(sourceContact.getContactUpdated());
-       }
-
-       /**
-        * Checks whether both contacts are same, but ignoring id number. If you
-        * want to include id number in comparison, better use Objects.equals() as
-        * the equal() method is implemented and checks all fields.
-        * <p>
-        * @param contact Contact one
-        * @param other   Contact two
-        * <p>
-        * @return Whether both are the same
-        */
-       public static boolean isSameContact (final Contact contact, final Contact other) {
-               // Both should not be null
-               if (null == contact) {
-                       // First contact is null
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (null == other) {
-                       // Secondcontact is null
-                       throw new NullPointerException("other is null"); //NOI18N
-               }
-
-               // Check all data fields, except id number
-               return ((Objects.equals(contact.getContactBirthday(), other.getContactBirthday())) &&
-                               (Objects.equals(contact.getContactCity(), other.getContactCity())) &&
-                               (Objects.equals(contact.getContactCountry(), other.getContactCountry())) &&
-                               (Objects.equals(contact.getContactEmailAddress(), other.getContactEmailAddress())) &&
-                               (Objects.equals(contact.getContactFamilyName(), other.getContactFamilyName())) &&
-                               (Objects.equals(contact.getContactFirstName(), other.getContactFirstName())) &&
-                               (Objects.equals(contact.getContactPersonalTitle(), other.getContactPersonalTitle())) &&
-                               (Objects.equals(contact.getContactHouseNumber(), other.getContactHouseNumber())) &&
-                               (Objects.equals(contact.getContactStreet(), other.getContactStreet())) &&
-                               (Objects.equals(contact.getContactTitle(), other.getContactTitle())) &&
-                               (Objects.equals(contact.getContactZipCode(), other.getContactZipCode())));
-       }
-
-       /**
-        * Updates land-line data in contact instance. This method also removes the
-        * land-line instance if no country is selected. A bean (mostly EJB) should
-        * then make sure that the land-line entry is being unlinked from contact
-        * instance or being removed, if no longer used.
-        * <p>
-        * @param contact     Contact instance being updated
-        * @param faxCountry  Updated fax number or null
-        * @param faxAreaCode Updated fax area code or null
-        * @param faxNumber   Updated fax number
-        * <p>
-        * @return Whether the fax number has been unlinked in contact object
-        */
-       public static boolean updateFaxNumber (final Contact contact, final Country faxCountry, final Integer faxAreaCode, final Long faxNumber) {
-               // At least contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-
-               // Default is not unlinked
-               boolean isUnlinked = false;
-
-               // Is there a fax instance?
-               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
-                       // Found existing fax number, remove it?
-                       if ((null == faxCountry) || (null == faxAreaCode) || (null == faxNumber)) {
-                               // Remove existing instance
-                               contact.setContactFaxNumber(null);
-
-                               // Mark it as being removed
-                               isUnlinked = true;
-                       } else {
-                               // Set all data
-                               contact.getContactFaxNumber().setPhoneCountry(faxCountry);
-                               contact.getContactFaxNumber().setPhoneAreaCode(faxAreaCode);
-                               contact.getContactFaxNumber().setPhoneNumber(faxNumber);
-                       }
-               } else if ((faxCountry instanceof Country) && (faxAreaCode > 0) && (faxNumber > 0)) {
-                       // Set new land-line number
-                       DialableFaxNumber fax = new FaxNumber(faxCountry, faxAreaCode, faxNumber);
-
-                       // Set it in contact
-                       contact.setContactFaxNumber(fax);
-               }
-
-               // Return status
-               return isUnlinked;
-       }
-
-       /**
-        * Updates land-line data in contact instance. This method also removes the
-        * land-line instance if no country is selected. A bean (mostly EJB) should
-        * then make sure that the land-line entry is being unlinked from contact
-        * instance or being removed, if no longer used.
-        * <p>
-        * @param contact       Contact instance being updated
-        * @param phoneCountry  New phone country or old or null
-        * @param phoneAreaCode New phone's area code (or old)
-        * @param phoneNumber   New phone number (or old)
-        * <p>
-        * @return Whether the land-line number has been unlinked in contact object
-        */
-       public static boolean updateLandLineNumber (final Contact contact, final Country phoneCountry, final Integer phoneAreaCode, final Long phoneNumber) {
-               // At least contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-
-               // Default is not unlinked
-               boolean isUnlinked = false;
-
-               // Is there a land-line instance?
-               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
-                       // Found existing land-line number, remove it?
-                       if ((null == phoneCountry) || (null == phoneAreaCode) || (null == phoneNumber)) {
-                               // Remove existing instance
-                               contact.setContactLandLineNumber(null);
-
-                               // Mark it as being removed
-                               isUnlinked = true;
-                       } else {
-                               // Set all data
-                               contact.getContactLandLineNumber().setPhoneCountry(phoneCountry);
-                               contact.getContactLandLineNumber().setPhoneAreaCode(phoneAreaCode);
-                               contact.getContactLandLineNumber().setPhoneNumber(phoneNumber);
-                       }
-               } else if ((phoneCountry instanceof Country) && (phoneAreaCode > 0) && (phoneNumber > 0)) {
-                       // Set new land-line number
-                       DialableLandLineNumber landLine = new LandLineNumber(phoneCountry, phoneAreaCode, phoneNumber);
-
-                       // Set it in contact
-                       contact.setContactLandLineNumber(landLine);
-               }
-
-               // Return status
-               return isUnlinked;
-       }
-
-       /**
-        * Updates mobile data in contact instance. This method also removes the
-        * mobile instance if no provider is selected. A bean (mostly EJB) should
-        * then make sure that the mobile entry is being unlinked from contact
-        * instance or being removed, if no longer used.
-        * <p>
-        * @param contact        Contact instance to update
-        * @param mobileProvider New mobile provider (or old)
-        * @param mobileNumber   New mobile number (or old)
-        * <p>
-        * @return Whether the mobile has been unlinked in contact object
-        */
-       public static boolean updateMobileNumber (final Contact contact, final MobileProvider mobileProvider, final Long mobileNumber) {
-               // At least contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if ((mobileProvider instanceof MobileProvider) && (null == mobileNumber)) {
-                       // Mobile provider given, but no number
-                       throw new NullPointerException("mobileNumber is null"); //NOI18N
-               }
-
-               // Default is not unlinked
-               boolean isUnlinked = false;
-
-               // Is there a mobile number?
-               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
-                       // Is provider null?
-                       if ((null == mobileProvider) || (null == mobileNumber) || (mobileNumber == 0)) {
-                               // Remove instance
-                               contact.setContactMobileNumber(null);
-
-                               // Mark as unlinked
-                               isUnlinked = true;
-                       } else {
-                               // Yes, then update as well
-                               contact.getContactMobileNumber().setMobileProvider(mobileProvider);
-                               contact.getContactMobileNumber().setPhoneNumber(mobileNumber);
-                       }
-               } else if ((mobileProvider instanceof MobileProvider) && (mobileNumber > 0)) {
-                       // Create new instance
-                       DialableMobileNumber mobile = new MobileNumber(mobileProvider, mobileNumber);
-
-                       // Set it in contact
-                       contact.setContactMobileNumber(mobile);
-               }
-
-               // Return status
-               return isUnlinked;
-       }
-
-       /**
-        * Private constructor for utilities
-        */
-       private ContactUtils () {
-       }
-
-}
diff --git a/src/org/mxchange/jcontacts/contact/UserContact.java b/src/org/mxchange/jcontacts/contact/UserContact.java
deleted file mode 100644 (file)
index 6a61c8b..0000000
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * 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;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Index;
-import javax.persistence.JoinColumn;
-import javax.persistence.Lob;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-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;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
-
-/**
- * A general contact class which serves as an entity.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- * @version 0.0
- */
-@Entity (name = "contacts")
-@Table (
-               name = "contacts",
-               indexes = {
-                       @Index (
-                                       name = "contact_personal_title",
-                                       columnList = "contact_personal_title"
-                       )
-               }
-)
-@NamedQueries (
-               {
-                       @NamedQuery (name = "AllContacts", query = "SELECT c FROM contacts AS c ORDER BY c.contactId ASC"),
-                       @NamedQuery (name = "AllContactEmailAddresses", query = "SELECT c.contactEmailAddress FROM contacts AS c ORDER BY c.contactId ASC"),
-                       @NamedQuery (name = "AllContactsByCellphone", query = "SELECT c FROM contacts AS c WHERE c.contactMobileNumber = :mobileNumber ORDER BY c.contactId ASC"),
-                       @NamedQuery (name = "SearchContact", query = "SELECT c FROM contacts AS c WHERE c = :contact"),
-                       @NamedQuery (name = "SearchContactById", query = "SELECT c FROM contacts AS c WHERE c.contactId = :contactId"),
-                       @NamedQuery (name = "SearchContactByEmailAddress", query = "SELECT c FROM contacts AS c WHERE LOWER(c.contactEmailAddress) LIKE LOWER(:emailAddress)")
-               }
-)
-@SuppressWarnings ("PersistenceUnitPresent")
-public class UserContact implements Contact {
-
-       /**
-        * Serial number
-        */
-       @Transient
-       private static final long serialVersionUID = 58_744_284_981_863L;
-
-       /**
-        * Birth day
-        */
-       @Column (name = "contact_birthday")
-       @Temporal (TemporalType.DATE)
-       private Date contactBirthday;
-
-       /**
-        * City
-        */
-       @Column (name = "contact_city", length = 100)
-       private String contactCity;
-
-       /**
-        * Optional comments
-        */
-       @Lob
-       @Column (name = "contact_comment")
-       private String contactComment;
-
-       /**
-        * Country code
-        */
-       @JoinColumn (name = "contact_country_id", nullable = false, referencedColumnName = "country_id")
-       @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
-       private Country contactCountry;
-
-       /**
-        * When the contact has been created
-        */
-       @Basic (optional = false)
-       @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "contact_created", nullable = false)
-       private Calendar contactCreated;
-
-       /**
-        * Email address
-        */
-       @Column (name = "contact_email_address", length = 100, unique = true)
-       private String contactEmailAddress;
-
-       /**
-        * Family name
-        */
-       @Basic (optional = false)
-       @Column (name = "contact_family_name", length = 100, nullable = false)
-       private String contactFamilyName;
-
-       /**
-        * Fax number
-        */
-       @JoinColumn (name = "contact_fax_number_id", referencedColumnName = "fax_id", unique = true)
-       @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
-       private DialableFaxNumber contactFaxNumber;
-
-       /**
-        * First name
-        */
-       @Basic (optional = false)
-       @Column (name = "contact_first_name", length = 100, nullable = false)
-       private String contactFirstName;
-
-       /**
-        * House number
-        */
-       @Column (name = "contact_house_number")
-       private Short contactHouseNumber;
-
-       /**
-        * House number extension
-        */
-       @Column (name = "contact_house_number_extension", length = 5)
-       private String contactHouseNumberExtension;
-
-       /**
-        * Id number
-        */
-       @Id
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       @Column (name = "contact_id", nullable = false, updatable = false)
-       private Long contactId;
-
-       /**
-        * Cellphone number
-        */
-       @JoinColumn (name = "contact_mobile_number_id", referencedColumnName = "mobile_id", unique = true)
-       @OneToOne (targetEntity = MobileNumber.class, cascade = CascadeType.ALL)
-       private DialableMobileNumber contactMobileNumber;
-
-       /**
-        * Flag whether this contact is user's own data
-        */
-       @Basic (optional = false)
-       @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
-        */
-       @JoinColumn (name = "contact_landline_number_id", referencedColumnName = "landline_id", unique = true)
-       @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
-       private DialableLandLineNumber contactPhoneNumber;
-
-       /**
-        * Street
-        */
-       @Column (name = "contact_street")
-       private String contactStreet;
-
-       /**
-        * Title (Doctor, etc)
-        */
-       @Column (name = "contact_title")
-       private String contactTitle;
-
-       /**
-        * When the contact has been updated
-        */
-       @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "contact_updated")
-       private Calendar contactUpdated;
-
-       /**
-        * ZIP code
-        */
-       @Column (name = "contact_zip_code")
-       private Integer contactZipCode;
-
-       /**
-        * Default constructor
-        */
-       public UserContact () {
-               // Default is not user's own contact
-               this.contactOwnContact = Boolean.FALSE;
-       }
-
-       /**
-        * Constructor for title and names
-        * <p>
-        * @param contactTitle      Personal title
-        * @param contactFirstName  First name
-        * @param contactFamilyName Family name
-        */
-       public UserContact (final PersonalTitle contactTitle, final String contactFirstName, final String contactFamilyName) {
-               // Call default constructor
-               this();
-
-               // Set all
-               this.contactPersonalTitle = contactTitle;
-               this.contactFirstName = contactFirstName;
-               this.contactFamilyName = contactFamilyName;
-       }
-
-       @Override
-       public boolean equals (final Object object) {
-               if (this == object) {
-                       return true;
-               } else if (null == object) {
-                       return false;
-               } else if (this.getClass() != object.getClass()) {
-                       return false;
-               } else if (!(object instanceof Contact)) {
-                       // Not correct interface
-                       return false;
-               }
-
-               final Contact other = (Contact) object;
-
-               if (!Objects.equals(this.getContactId(), other.getContactId())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactCity(), other.getContactCity())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactEmailAddress(), other.getContactEmailAddress())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactFamilyName(), other.getContactFamilyName())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactFirstName(), other.getContactFirstName())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactStreet(), other.getContactStreet())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactTitle(), other.getContactTitle())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactBirthday(), other.getContactBirthday())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactCountry(), other.getContactCountry())) {
-                       return false;
-               } else if (this.getContactPersonalTitle() != other.getContactPersonalTitle()) {
-                       return false;
-               } else if (!Objects.equals(this.getContactHouseNumber(), other.getContactHouseNumber())) {
-                       return false;
-               } else if (!Objects.equals(this.getContactHouseNumberExtension(), other.getContactHouseNumberExtension())) {
-                       return false;
-               }
-
-               return true;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getContactBirthday () {
-               return this.contactBirthday;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setContactBirthday (final Date contactBirthday) {
-               this.contactBirthday = contactBirthday;
-       }
-
-       @Override
-       public String getContactCity () {
-               return this.contactCity;
-       }
-
-       @Override
-       public void setContactCity (final String contactCity) {
-               this.contactCity = contactCity;
-       }
-
-       @Override
-       public String getContactComment () {
-               return this.contactComment;
-       }
-
-       @Override
-       public void setContactComment (final String contactComment) {
-               this.contactComment = contactComment;
-       }
-
-       @Override
-       public Country getContactCountry () {
-               return this.contactCountry;
-       }
-
-       @Override
-       public void setContactCountry (final Country contactCountry) {
-               this.contactCountry = contactCountry;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Calendar getContactCreated () {
-               return this.contactCreated;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setContactCreated (final Calendar contactCreated) {
-               this.contactCreated = contactCreated;
-       }
-
-       @Override
-       public String getContactEmailAddress () {
-               return this.contactEmailAddress;
-       }
-
-       @Override
-       public void setContactEmailAddress (final String contactEmailAddress) {
-               this.contactEmailAddress = contactEmailAddress;
-       }
-
-       @Override
-       public String getContactFamilyName () {
-               //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
-               return this.contactFamilyName;
-       }
-
-       @Override
-       public void setContactFamilyName (final String contactFamilyName) {
-               this.contactFamilyName = contactFamilyName;
-       }
-
-       @Override
-       public DialableFaxNumber getContactFaxNumber () {
-               return this.contactFaxNumber;
-       }
-
-       @Override
-       public void setContactFaxNumber (final DialableFaxNumber contactFaxNumber) {
-               this.contactFaxNumber = contactFaxNumber;
-       }
-
-       @Override
-       public String getContactFirstName () {
-               return this.contactFirstName;
-       }
-
-       @Override
-       public void setContactFirstName (final String contactFirstName) {
-               this.contactFirstName = contactFirstName;
-       }
-
-       @Override
-       public Short getContactHouseNumber () {
-               return this.contactHouseNumber;
-       }
-
-       @Override
-       public void setContactHouseNumber (final Short contactHouseNumber) {
-               this.contactHouseNumber = contactHouseNumber;
-       }
-
-       @Override
-       public String getContactHouseNumberExtension () {
-               return this.contactHouseNumberExtension;
-       }
-
-       @Override
-       public void setContactHouseNumberExtension (final String contactHouseNumberExtension) {
-               this.contactHouseNumberExtension = contactHouseNumberExtension;
-       }
-
-       @Override
-       public Long getContactId () {
-               return this.contactId;
-       }
-
-       @Override
-       public void setContactId (final Long contactId) {
-               this.contactId = contactId;
-       }
-
-       @Override
-       public DialableLandLineNumber getContactLandLineNumber () {
-               return this.contactPhoneNumber;
-       }
-
-       @Override
-       public void setContactLandLineNumber (final DialableLandLineNumber contactPhoneNumber) {
-               this.contactPhoneNumber = contactPhoneNumber;
-       }
-
-       @Override
-       public DialableMobileNumber getContactMobileNumber () {
-               return this.contactMobileNumber;
-       }
-
-       @Override
-       public void setContactMobileNumber (final DialableMobileNumber contactMobileNumber) {
-               this.contactMobileNumber = contactMobileNumber;
-       }
-
-       @Override
-       public void setContactOwnContact (final Boolean contactOwnContact) {
-               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;
-       }
-
-       @Override
-       public void setContactStreet (final String contactStreet) {
-               this.contactStreet = contactStreet;
-       }
-
-       @Override
-       public String getContactTitle () {
-               return this.contactTitle;
-       }
-
-       @Override
-       public void setContactTitle (final String contactTitle) {
-               this.contactTitle = contactTitle;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Calendar getContactUpdated () {
-               return this.contactUpdated;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setContactUpdated (final Calendar contactUpdated) {
-               this.contactUpdated = contactUpdated;
-       }
-
-       @Override
-       public Integer getContactZipCode () {
-               return this.contactZipCode;
-       }
-
-       @Override
-       public void setContactZipCode (final Integer contactZipCode) {
-               this.contactZipCode = contactZipCode;
-       }
-
-       @Override
-       public int hashCode () {
-               int hash = 5;
-
-               hash = 29 * hash + Objects.hashCode(this.getContactBirthday());
-               hash = 29 * hash + Objects.hashCode(this.getContactCity());
-               hash = 29 * hash + Objects.hashCode(this.getContactCountry());
-               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.getContactPersonalTitle());
-               hash = 29 * hash + Objects.hashCode(this.getContactHouseNumber());
-               hash = 29 * hash + Objects.hashCode(this.getContactHouseNumberExtension());
-               hash = 29 * hash + Objects.hashCode(this.getContactId());
-               hash = 29 * hash + Objects.hashCode(this.getContactStreet());
-               hash = 29 * hash + Objects.hashCode(this.getContactTitle());
-
-               return hash;
-       }
-
-       @Override
-       public Boolean isOwnContact () {
-               return this.contactOwnContact;
-       }
-
-}
diff --git a/src/org/mxchange/jcontacts/contact/gender/Gender.java b/src/org/mxchange/jcontacts/contact/gender/Gender.java
deleted file mode 100644 (file)
index b06b94d..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.gender;
-
-import java.io.Serializable;
-
-/**
- * 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 gender
-        */
-       MALE('M', "GENDER_MALE"), //NOI18N
-
-       /**
-        * Female gender
-        */
-       FEMALE('F', "GENDER_FEMALE"); //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 Gender (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;
-       }
-
-}
diff --git a/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java b/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java
deleted file mode 100644 (file)
index 87ec6e8..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.gender;
-
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Gender utils class
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class GenderUtils implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 185_683_479_107L;
-
-       /**
-        * Cache for valid chars
-        */
-       private static char[] validChars;
-
-       /**
-        * All available genders as a list
-        * <p>
-        * @return Selectable genders (not UNKNOWN)
-        */
-       public static List<Gender> allGendersAsList () {
-               // Init list
-               List<Gender> list = new LinkedList<>();
-
-               // Walk through all genders
-               for (final Gender gender : Gender.values()) {
-                       // Add it and check if it has been added
-                       list.add(gender);
-               }
-
-               // Return it
-               return list;
-       }
-
-       /**
-        * 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 () {
-       }
-
-}
diff --git a/src/org/mxchange/jcontacts/contact/title/PersonalTitle.java b/src/org/mxchange/jcontacts/contact/title/PersonalTitle.java
deleted file mode 100644 (file)
index 8a88902..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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;
-       }
-
-}
diff --git a/src/org/mxchange/jcontacts/contact/title/TitleUtils.java b/src/org/mxchange/jcontacts/contact/title/TitleUtils.java
deleted file mode 100644 (file)
index 492f5ef..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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 () {
-       }
-
-}
index 1e1dd70b0687464c58309d90136b5b0261974808..3ec34811d6165809e60a432efc1f1079ba7b33cf 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.events.contact.add;
 
 import java.text.MessageFormat;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An event being fired when the administrator has added a new user account
index 8346b319abd235299e6ef3cd30b7165c26a724d2..feef6ebffc1fd3159e2dd5ebbad9bc6000983570 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.events.contact.add;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An interface for events being fired when an administrator added new contact
index 29d69e17b9ea9d3884d657b72f8ea560b8d26d1e..7f7fb55bca29aaa654fa9a050968ff9c827f60d5 100644 (file)
@@ -16,7 +16,7 @@
  */
 package org.mxchange.jcontacts.events.contact.created;
 
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An interface for observable events being fired when a contact instance has
index edda2654385e9180c9fe35a36ff6607d90707f8b..777b3ae831d58cd8cb5a63671433f71cfbb1fc6d 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.events.contact.created;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An interface for observable events being fired when a contact instance has
index 3bc3cc27da1e98ac9aa912d7a7e655a5445a6bc9..ff2b5e716499c94b295faa3e59ef2e214e3c65d1 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.events.contact.deleted;
 
 import java.text.MessageFormat;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An event being fired when the administrator has deleted a contact
index 0427df959efbb0e57dc817c0a5748ba4e88f1ba2..8b096435b5b1182ea2517172e5c7eb68bc692395 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.events.contact.deleted;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An interface for events being fired when an administrator deleted a contact.
index 51e691f986c57b3dd4d8e1bdb148db3bd20e7539..881ff4e45a42c4060670478d64de843c7291c280 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.events.contact.update;
 
 import java.text.MessageFormat;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An event being fired when the administrator has updated a new user account
index 845fae8f732dffd524d268caf5420ca889c7db44..87182eec238691628e37725af73c80b4d6b1c53f 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.events.contact.update;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * An interface for events being fired when an administrator updated a new user
index 2bd28e2a59ec40942b922f41c4710449f58cc774..eb71aacfef7f10ff65518f88495e90033fbd7473 100644 (file)
@@ -16,8 +16,8 @@
  */
 package org.mxchange.jcontacts.events.fax.linked;
 
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 
 /**
  * An event when a fax number has been linked with a contact
index 962606d9ce415fe282944d2c2b63eef3100a381d..afc7286ec525a5b194abedfbcb5766cb44b9cbdb 100644 (file)
@@ -17,8 +17,8 @@
 package org.mxchange.jcontacts.events.fax.linked;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 
 /**
  * An interface for an event when a fax number has been linked with a contact
index ff1e769c72ad77d4412752206a664b67ed64ebe9..764f5d32af013e57222914c1c08d2a699afe6981 100644 (file)
@@ -16,8 +16,8 @@
  */
 package org.mxchange.jcontacts.events.fax.unlinked;
 
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 
 /**
  * An event when a fax number has been unlinked
index d6c9b99e33c17baba8d24ae36507506cabef503f..51082d18c5cf3ef29322806425ecf4e4cba5120c 100644 (file)
@@ -17,8 +17,8 @@
 package org.mxchange.jcontacts.events.fax.unlinked;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 
 /**
  * An interface for an event when a fax number has been unlinked
index 89f39f51603caf5086a2e3fa02d5ddfe82dc10ec..01ef3e4e408f7c7700c01731db73ff209152831f 100644 (file)
@@ -16,8 +16,8 @@
  */
 package org.mxchange.jcontacts.events.landline.linked;
 
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
 
 /**
  * An event when a land-line number has been linked with a contact
index d02597fd8f34cda6998ee7c20ad1b24accb3ac26..c4e04f60f1afb4f37e88f1262802f76e3534d1fc 100644 (file)
@@ -17,8 +17,8 @@
 package org.mxchange.jcontacts.events.landline.linked;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
 
 /**
  * An interface for an event when a land-line number has been linked with a
index 93efedcb429b7799e295625aaff4d7b3db66c170..4a46001e684bc894b06d888633f2e7b944480d41 100644 (file)
@@ -16,8 +16,8 @@
  */
 package org.mxchange.jcontacts.events.landline.unlinked;
 
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
 
 /**
  * An event when a land-line number has been unlinked
index 90f20510e5c5ca9e18d2274e0aedd3e0354b2e7b..bc6cbc717e8328e36b957b2cf1dd3d627c47981d 100644 (file)
@@ -17,8 +17,8 @@
 package org.mxchange.jcontacts.events.landline.unlinked;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
 
 /**
  * An interface for an event when a land-line number has been unlinked
index bda30bf83a5fceb4fb24be3d7de0592e8aeca89e..f681f202131c2faa313e3be4a8b53a28260fffb1 100644 (file)
@@ -16,8 +16,8 @@
  */
 package org.mxchange.jcontacts.events.mobile.linked;
 
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 
 /**
  * An event when a mobile number has been linked with a contact
index 8ba8813c260a1f8b05b06d8e51277112100259b4..580b48abf939d448751271904d68fb757f754422 100644 (file)
@@ -17,8 +17,8 @@
 package org.mxchange.jcontacts.events.mobile.linked;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 
 /**
  * An interface for an event when a mobile number has been linked with a contact
index 03f09b37c4e9032ee760137316c2561c916fb7ce..b7a95897958a18b81bec42c7f5e150c7f56a22a4 100644 (file)
@@ -16,8 +16,8 @@
  */
 package org.mxchange.jcontacts.events.mobile.unlinked;
 
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 
 /**
  * An event when a mobile number has been unlinked
index daa64e15ed8c2f0b11358a82b858064796924cdb..f85862cc314f121b411823a99eabb1cecc0b63a8 100644 (file)
@@ -17,8 +17,8 @@
 package org.mxchange.jcontacts.events.mobile.unlinked;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 
 /**
  * An interface for an event when a mobile number has been unlinked
index 4ccd3ce36a43ba9b9009f5a44fa16098718de350..062966a2ea8c762fa248d58880dfeefcfa6eff5e 100644 (file)
@@ -17,7 +17,7 @@
 package org.mxchange.jcontacts.exceptions;
 
 import java.text.MessageFormat;
-import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contact;
 
 /**
  * Thrown if the given Contact instance is already added
diff --git a/src/org/mxchange/jcontacts/model/contact/Contact.java b/src/org/mxchange/jcontacts/model/contact/Contact.java
new file mode 100644 (file)
index 0000000..4eb2f5a
--- /dev/null
@@ -0,0 +1,329 @@
+/*
+ * 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.model.contact;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+
+/**
+ * A general contact POJI
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface Contact extends Serializable {
+
+       /**
+        * Birth day
+        * <p>
+        * @return the birthday
+        */
+       Date getContactBirthday ();
+
+       /**
+        * Birth day
+        * <p>
+        * @param birthday the birthday to set
+        */
+       void setContactBirthday (final Date birthday);
+
+       /**
+        * Getter for mobile number
+        * <p>
+        * @return Mobile number
+        */
+       DialableMobileNumber getContactMobileNumber ();
+
+       /**
+        * Setter for mobile number
+        * <p>
+        * @param mobileNumber Mobile number
+        */
+       void setContactMobileNumber (final DialableMobileNumber mobileNumber);
+
+       /**
+        * City
+        * <p>
+        * @return the city
+        */
+       String getContactCity ();
+
+       /**
+        * City
+        * <p>
+        * @param city the city to set
+        */
+       void setContactCity (final String city);
+
+       /**
+        * Comments
+        * <p>
+        * @return the comment
+        */
+       String getContactComment ();
+
+       /**
+        * Comments
+        * <p>
+        * @param comment the comment to set
+        */
+       void setContactComment (final String comment);
+
+       /**
+        * Id number
+        * <p>
+        * @return the contactId
+        */
+       Long getContactId ();
+
+       /**
+        * Id number
+        * <p>
+        * @param id the contactId to set
+        */
+       void setContactId (final Long id);
+
+       /**
+        * Country code
+        * <p>
+        * @return the countryCode
+        */
+       Country getContactCountry ();
+
+       /**
+        * Country code
+        * <p>
+        * @param contactCountry the countryCode to set
+        */
+       void setContactCountry (final Country contactCountry);
+
+       /**
+        * Getter for "created" timestamp
+        * <p>
+        * @return "created" timestamp
+        */
+       Calendar getContactCreated ();
+
+       /**
+        * Setter for "created" timestamp
+        * <p>
+        * @param created "created" timestamp
+        */
+       void setContactCreated (final Calendar created);
+
+       /**
+        * Email address
+        * <p>
+        * @return the emailAddress
+        */
+       String getContactEmailAddress ();
+
+       /**
+        * Email address
+        * <p>
+        * @param emailAddress the emailAddress to set
+        */
+       void setContactEmailAddress (final String emailAddress);
+
+       /**
+        * Family name
+        * <p>
+        * @return the familyName
+        */
+       String getContactFamilyName ();
+
+       /**
+        * Family name
+        * <p>
+        * @param familyName the familyName to set
+        */
+       void setContactFamilyName (final String familyName);
+
+       /**
+        * Fax number
+        * <p>
+        * @return the faxNumber
+        */
+       DialableFaxNumber getContactFaxNumber ();
+
+       /**
+        * Fax number
+        * <p>
+        * @param faxNumber the faxNumber to set
+        */
+       void setContactFaxNumber (final DialableFaxNumber faxNumber);
+
+       /**
+        * First name
+        * <p>
+        * @return the first name
+        */
+       String getContactFirstName ();
+
+       /**
+        * First name
+        * <p>
+        * @param firstName the first name to set
+        */
+       void setContactFirstName (final String firstName);
+
+       /**
+        * Getter for personal title
+        * <p>
+        * @return Personal title
+        */
+       PersonalTitle getContactPersonalTitle ();
+
+       /**
+        * Setter for personal title
+        * <p>
+        * @param personalTitle Personal title
+        */
+       void setContactPersonalTitle (final PersonalTitle personalTitle);
+
+       /**
+        * House number
+        * <p>
+        * @return the houseNumber
+        */
+       Short getContactHouseNumber ();
+
+       /**
+        * House number
+        * <p>
+        * @param houseNumber the houseNumber to set
+        */
+       void setContactHouseNumber (final Short houseNumber);
+
+       /**
+        * Getter for house number extension, example: 123a 'a' is then the
+        * extension and 123 is the house number.
+        * <p>
+        * @return House number extension
+        */
+       String getContactHouseNumberExtension ();
+
+       /**
+        * Setter for house number extension
+        * <p>
+        * @param contactHouseNumberExtension House number extension
+        */
+       void setContactHouseNumberExtension (final String contactHouseNumberExtension);
+
+       /**
+        * Setter for own contact
+        * <p>
+        * @param ownContact Own contact
+        */
+       void setContactOwnContact (final Boolean ownContact);
+
+       /**
+        * Getter for phone number
+        * <p>
+        * @return Phone number
+        */
+       DialableLandLineNumber getContactLandLineNumber ();
+
+       /**
+        * Setter for phone number
+        * <p>
+        * @param phoneNumber Phone number
+        */
+       void setContactLandLineNumber (final DialableLandLineNumber phoneNumber);
+
+       /**
+        * Street
+        * <p>
+        * @return the street
+        */
+       String getContactStreet ();
+
+       /**
+        * Street
+        * <p>
+        * @param street the street to set
+        */
+       void setContactStreet (final String street);
+
+       /**
+        * Getter for contact's title
+        * <p>
+        * @return Contact's title
+        */
+       String getContactTitle ();
+
+       /**
+        * Setter for contact's title
+        * <p>
+        * @param contactTitle Contact's title
+        */
+       void setContactTitle (final String contactTitle);
+
+       /**
+        * Getter for "updated" timestamp
+        * <p>
+        * @return "updated" timestamp
+        */
+       Calendar getContactUpdated ();
+
+       /**
+        * Getter for "updated" timestamp
+        * <p>
+        * @param updated "updated" timestamp
+        */
+       void setContactUpdated (final Calendar updated);
+
+       /**
+        * ZIP code
+        * <p>
+        * @return the zipCode
+        */
+       Integer getContactZipCode ();
+
+       /**
+        * ZIP code
+        * <p>
+        * @param zipCode the zipCode to set
+        */
+       void setContactZipCode (final Integer zipCode);
+
+       /**
+        * Checks whether the contact is user's own data
+        * <p>
+        * @return Own data?
+        */
+       Boolean isOwnContact ();
+
+       /**
+        * Check if contacts are same or throw an exception
+        * <p>
+        * @param object Other possible contact class
+        * <p>
+        * @return Whether both contacts are same
+        */
+       @Override
+       boolean equals (final Object object);
+
+       @Override
+       int hashCode ();
+
+}
diff --git a/src/org/mxchange/jcontacts/model/contact/ContactUtils.java b/src/org/mxchange/jcontacts/model/contact/ContactUtils.java
new file mode 100644 (file)
index 0000000..8397012
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * 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.model.contact;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * Utilities for contacts
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class ContactUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 26_785_734_719_670L;
+
+       /**
+        * Copies all attributes from other contact object to this
+        * <p>
+        * @param sourceContact Source instance
+        * @param targetContact Target instance
+        */
+       public static void copyAll (final Contact sourceContact, final Contact targetContact) {
+               // Contact should be valid
+               if (null == sourceContact) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceContact is null"); //NOI18N
+               } else if (null == targetContact) {
+                       // Throw NPE
+                       throw new NullPointerException("targetContact is null"); //NOI18N
+               }
+
+               // Copy all:
+               // - base data
+               targetContact.setContactPersonalTitle(sourceContact.getContactPersonalTitle());
+               targetContact.setContactTitle(sourceContact.getContactTitle());
+               targetContact.setContactFirstName(sourceContact.getContactFirstName());
+               targetContact.setContactFamilyName(sourceContact.getContactFamilyName());
+               targetContact.setContactStreet(sourceContact.getContactStreet());
+               targetContact.setContactHouseNumber(sourceContact.getContactHouseNumber());
+               targetContact.setContactHouseNumberExtension(sourceContact.getContactHouseNumberExtension());
+               targetContact.setContactZipCode(sourceContact.getContactZipCode());
+               targetContact.setContactCity(sourceContact.getContactCity());
+               targetContact.setContactCountry(sourceContact.getContactCountry());
+
+               // - phone, fax, email
+               targetContact.setContactLandLineNumber(sourceContact.getContactLandLineNumber());
+               targetContact.setContactFaxNumber(sourceContact.getContactFaxNumber());
+               targetContact.setContactMobileNumber(sourceContact.getContactMobileNumber());
+
+               // - other data
+               targetContact.setContactBirthday(sourceContact.getContactBirthday());
+               targetContact.setContactComment(sourceContact.getContactComment());
+               targetContact.setContactCreated(sourceContact.getContactCreated());
+               targetContact.setContactUpdated(sourceContact.getContactUpdated());
+       }
+
+       /**
+        * Checks whether both contacts are same, but ignoring id number. If you
+        * want to include id number in comparison, better use Objects.equals() as
+        * the equal() method is implemented and checks all fields.
+        * <p>
+        * @param contact Contact one
+        * @param other   Contact two
+        * <p>
+        * @return Whether both are the same
+        */
+       public static boolean isSameContact (final Contact contact, final Contact other) {
+               // Both should not be null
+               if (null == contact) {
+                       // First contact is null
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (null == other) {
+                       // Secondcontact is null
+                       throw new NullPointerException("other is null"); //NOI18N
+               }
+
+               // Check all data fields, except id number
+               return ((Objects.equals(contact.getContactBirthday(), other.getContactBirthday())) &&
+                               (Objects.equals(contact.getContactCity(), other.getContactCity())) &&
+                               (Objects.equals(contact.getContactCountry(), other.getContactCountry())) &&
+                               (Objects.equals(contact.getContactEmailAddress(), other.getContactEmailAddress())) &&
+                               (Objects.equals(contact.getContactFamilyName(), other.getContactFamilyName())) &&
+                               (Objects.equals(contact.getContactFirstName(), other.getContactFirstName())) &&
+                               (Objects.equals(contact.getContactPersonalTitle(), other.getContactPersonalTitle())) &&
+                               (Objects.equals(contact.getContactHouseNumber(), other.getContactHouseNumber())) &&
+                               (Objects.equals(contact.getContactStreet(), other.getContactStreet())) &&
+                               (Objects.equals(contact.getContactTitle(), other.getContactTitle())) &&
+                               (Objects.equals(contact.getContactZipCode(), other.getContactZipCode())));
+       }
+
+       /**
+        * Updates land-line data in contact instance. This method also removes the
+        * land-line instance if no country is selected. A bean (mostly EJB) should
+        * then make sure that the land-line entry is being unlinked from contact
+        * instance or being removed, if no longer used.
+        * <p>
+        * @param contact     Contact instance being updated
+        * @param faxCountry  Updated fax number or null
+        * @param faxAreaCode Updated fax area code or null
+        * @param faxNumber   Updated fax number
+        * <p>
+        * @return Whether the fax number has been unlinked in contact object
+        */
+       public static boolean updateFaxNumber (final Contact contact, final Country faxCountry, final Integer faxAreaCode, final Long faxNumber) {
+               // At least contact must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+
+               // Default is not unlinked
+               boolean isUnlinked = false;
+
+               // Is there a fax instance?
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // Found existing fax number, remove it?
+                       if ((null == faxCountry) || (null == faxAreaCode) || (null == faxNumber)) {
+                               // Remove existing instance
+                               contact.setContactFaxNumber(null);
+
+                               // Mark it as being removed
+                               isUnlinked = true;
+                       } else {
+                               // Set all data
+                               contact.getContactFaxNumber().setPhoneCountry(faxCountry);
+                               contact.getContactFaxNumber().setPhoneAreaCode(faxAreaCode);
+                               contact.getContactFaxNumber().setPhoneNumber(faxNumber);
+                       }
+               } else if ((faxCountry instanceof Country) && (faxAreaCode > 0) && (faxNumber > 0)) {
+                       // Set new land-line number
+                       DialableFaxNumber fax = new FaxNumber(faxCountry, faxAreaCode, faxNumber);
+
+                       // Set it in contact
+                       contact.setContactFaxNumber(fax);
+               }
+
+               // Return status
+               return isUnlinked;
+       }
+
+       /**
+        * Updates land-line data in contact instance. This method also removes the
+        * land-line instance if no country is selected. A bean (mostly EJB) should
+        * then make sure that the land-line entry is being unlinked from contact
+        * instance or being removed, if no longer used.
+        * <p>
+        * @param contact       Contact instance being updated
+        * @param phoneCountry  New phone country or old or null
+        * @param phoneAreaCode New phone's area code (or old)
+        * @param phoneNumber   New phone number (or old)
+        * <p>
+        * @return Whether the land-line number has been unlinked in contact object
+        */
+       public static boolean updateLandLineNumber (final Contact contact, final Country phoneCountry, final Integer phoneAreaCode, final Long phoneNumber) {
+               // At least contact must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+
+               // Default is not unlinked
+               boolean isUnlinked = false;
+
+               // Is there a land-line instance?
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // Found existing land-line number, remove it?
+                       if ((null == phoneCountry) || (null == phoneAreaCode) || (null == phoneNumber)) {
+                               // Remove existing instance
+                               contact.setContactLandLineNumber(null);
+
+                               // Mark it as being removed
+                               isUnlinked = true;
+                       } else {
+                               // Set all data
+                               contact.getContactLandLineNumber().setPhoneCountry(phoneCountry);
+                               contact.getContactLandLineNumber().setPhoneAreaCode(phoneAreaCode);
+                               contact.getContactLandLineNumber().setPhoneNumber(phoneNumber);
+                       }
+               } else if ((phoneCountry instanceof Country) && (phoneAreaCode > 0) && (phoneNumber > 0)) {
+                       // Set new land-line number
+                       DialableLandLineNumber landLine = new LandLineNumber(phoneCountry, phoneAreaCode, phoneNumber);
+
+                       // Set it in contact
+                       contact.setContactLandLineNumber(landLine);
+               }
+
+               // Return status
+               return isUnlinked;
+       }
+
+       /**
+        * Updates mobile data in contact instance. This method also removes the
+        * mobile instance if no provider is selected. A bean (mostly EJB) should
+        * then make sure that the mobile entry is being unlinked from contact
+        * instance or being removed, if no longer used.
+        * <p>
+        * @param contact        Contact instance to update
+        * @param mobileProvider New mobile provider (or old)
+        * @param mobileNumber   New mobile number (or old)
+        * <p>
+        * @return Whether the mobile has been unlinked in contact object
+        */
+       public static boolean updateMobileNumber (final Contact contact, final MobileProvider mobileProvider, final Long mobileNumber) {
+               // At least contact must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if ((mobileProvider instanceof MobileProvider) && (null == mobileNumber)) {
+                       // Mobile provider given, but no number
+                       throw new NullPointerException("mobileNumber is null"); //NOI18N
+               }
+
+               // Default is not unlinked
+               boolean isUnlinked = false;
+
+               // Is there a mobile number?
+               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+                       // Is provider null?
+                       if ((null == mobileProvider) || (null == mobileNumber) || (mobileNumber == 0)) {
+                               // Remove instance
+                               contact.setContactMobileNumber(null);
+
+                               // Mark as unlinked
+                               isUnlinked = true;
+                       } else {
+                               // Yes, then update as well
+                               contact.getContactMobileNumber().setMobileProvider(mobileProvider);
+                               contact.getContactMobileNumber().setPhoneNumber(mobileNumber);
+                       }
+               } else if ((mobileProvider instanceof MobileProvider) && (mobileNumber > 0)) {
+                       // Create new instance
+                       DialableMobileNumber mobile = new MobileNumber(mobileProvider, mobileNumber);
+
+                       // Set it in contact
+                       contact.setContactMobileNumber(mobile);
+               }
+
+               // Return status
+               return isUnlinked;
+       }
+
+       /**
+        * Private constructor for utilities
+        */
+       private ContactUtils () {
+       }
+
+}
diff --git a/src/org/mxchange/jcontacts/model/contact/UserContact.java b/src/org/mxchange/jcontacts/model/contact/UserContact.java
new file mode 100644 (file)
index 0000000..7554f46
--- /dev/null
@@ -0,0 +1,518 @@
+/*
+ * 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.model.contact;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcountry.model.data.CountryData;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
+
+/**
+ * A general contact class which serves as an entity.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ * @version 0.0
+ */
+@Entity (name = "contacts")
+@Table (
+               name = "contacts",
+               indexes = {
+                       @Index (
+                                       name = "contact_personal_title",
+                                       columnList = "contact_personal_title"
+                       )
+               }
+)
+@NamedQueries (
+               {
+                       @NamedQuery (name = "AllContacts", query = "SELECT c FROM contacts AS c ORDER BY c.contactId ASC"),
+                       @NamedQuery (name = "AllContactEmailAddresses", query = "SELECT c.contactEmailAddress FROM contacts AS c ORDER BY c.contactId ASC"),
+                       @NamedQuery (name = "AllContactsByCellphone", query = "SELECT c FROM contacts AS c WHERE c.contactMobileNumber = :mobileNumber ORDER BY c.contactId ASC"),
+                       @NamedQuery (name = "SearchContact", query = "SELECT c FROM contacts AS c WHERE c = :contact"),
+                       @NamedQuery (name = "SearchContactById", query = "SELECT c FROM contacts AS c WHERE c.contactId = :contactId"),
+                       @NamedQuery (name = "SearchContactByEmailAddress", query = "SELECT c FROM contacts AS c WHERE LOWER(c.contactEmailAddress) LIKE LOWER(:emailAddress)")
+               }
+)
+@SuppressWarnings ("PersistenceUnitPresent")
+public class UserContact implements Contact {
+
+       /**
+        * Serial number
+        */
+       @Transient
+       private static final long serialVersionUID = 58_744_284_981_863L;
+
+       /**
+        * Birth day
+        */
+       @Column (name = "contact_birthday")
+       @Temporal (TemporalType.DATE)
+       private Date contactBirthday;
+
+       /**
+        * City
+        */
+       @Column (name = "contact_city", length = 100)
+       private String contactCity;
+
+       /**
+        * Optional comments
+        */
+       @Lob
+       @Column (name = "contact_comment")
+       private String contactComment;
+
+       /**
+        * Country code
+        */
+       @JoinColumn (name = "contact_country_id", nullable = false, referencedColumnName = "country_id")
+       @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
+       private Country contactCountry;
+
+       /**
+        * When the contact has been created
+        */
+       @Basic (optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "contact_created", nullable = false)
+       private Calendar contactCreated;
+
+       /**
+        * Email address
+        */
+       @Column (name = "contact_email_address", length = 100, unique = true)
+       private String contactEmailAddress;
+
+       /**
+        * Family name
+        */
+       @Basic (optional = false)
+       @Column (name = "contact_family_name", length = 100, nullable = false)
+       private String contactFamilyName;
+
+       /**
+        * Fax number
+        */
+       @JoinColumn (name = "contact_fax_number_id", referencedColumnName = "fax_id", unique = true)
+       @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
+       private DialableFaxNumber contactFaxNumber;
+
+       /**
+        * First name
+        */
+       @Basic (optional = false)
+       @Column (name = "contact_first_name", length = 100, nullable = false)
+       private String contactFirstName;
+
+       /**
+        * House number
+        */
+       @Column (name = "contact_house_number")
+       private Short contactHouseNumber;
+
+       /**
+        * House number extension
+        */
+       @Column (name = "contact_house_number_extension", length = 5)
+       private String contactHouseNumberExtension;
+
+       /**
+        * Id number
+        */
+       @Id
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       @Column (name = "contact_id", nullable = false, updatable = false)
+       private Long contactId;
+
+       /**
+        * Cellphone number
+        */
+       @JoinColumn (name = "contact_mobile_number_id", referencedColumnName = "mobile_id", unique = true)
+       @OneToOne (targetEntity = MobileNumber.class, cascade = CascadeType.ALL)
+       private DialableMobileNumber contactMobileNumber;
+
+       /**
+        * Flag whether this contact is user's own data
+        */
+       @Basic (optional = false)
+       @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
+        */
+       @JoinColumn (name = "contact_landline_number_id", referencedColumnName = "landline_id", unique = true)
+       @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
+       private DialableLandLineNumber contactPhoneNumber;
+
+       /**
+        * Street
+        */
+       @Column (name = "contact_street")
+       private String contactStreet;
+
+       /**
+        * Title (Doctor, etc)
+        */
+       @Column (name = "contact_title")
+       private String contactTitle;
+
+       /**
+        * When the contact has been updated
+        */
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "contact_updated")
+       private Calendar contactUpdated;
+
+       /**
+        * ZIP code
+        */
+       @Column (name = "contact_zip_code")
+       private Integer contactZipCode;
+
+       /**
+        * Default constructor
+        */
+       public UserContact () {
+               // Default is not user's own contact
+               this.contactOwnContact = Boolean.FALSE;
+       }
+
+       /**
+        * Constructor for title and names
+        * <p>
+        * @param contactTitle      Personal title
+        * @param contactFirstName  First name
+        * @param contactFamilyName Family name
+        */
+       public UserContact (final PersonalTitle contactTitle, final String contactFirstName, final String contactFamilyName) {
+               // Call default constructor
+               this();
+
+               // Set all
+               this.contactPersonalTitle = contactTitle;
+               this.contactFirstName = contactFirstName;
+               this.contactFamilyName = contactFamilyName;
+       }
+
+       @Override
+       public boolean equals (final Object object) {
+               if (this == object) {
+                       return true;
+               } else if (null == object) {
+                       return false;
+               } else if (this.getClass() != object.getClass()) {
+                       return false;
+               } else if (!(object instanceof Contact)) {
+                       // Not correct interface
+                       return false;
+               }
+
+               final Contact other = (Contact) object;
+
+               if (!Objects.equals(this.getContactId(), other.getContactId())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactCity(), other.getContactCity())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactEmailAddress(), other.getContactEmailAddress())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactFamilyName(), other.getContactFamilyName())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactFirstName(), other.getContactFirstName())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactStreet(), other.getContactStreet())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactTitle(), other.getContactTitle())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactBirthday(), other.getContactBirthday())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactCountry(), other.getContactCountry())) {
+                       return false;
+               } else if (this.getContactPersonalTitle() != other.getContactPersonalTitle()) {
+                       return false;
+               } else if (!Objects.equals(this.getContactHouseNumber(), other.getContactHouseNumber())) {
+                       return false;
+               } else if (!Objects.equals(this.getContactHouseNumberExtension(), other.getContactHouseNumberExtension())) {
+                       return false;
+               }
+
+               return true;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getContactBirthday () {
+               return this.contactBirthday;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setContactBirthday (final Date contactBirthday) {
+               this.contactBirthday = contactBirthday;
+       }
+
+       @Override
+       public String getContactCity () {
+               return this.contactCity;
+       }
+
+       @Override
+       public void setContactCity (final String contactCity) {
+               this.contactCity = contactCity;
+       }
+
+       @Override
+       public String getContactComment () {
+               return this.contactComment;
+       }
+
+       @Override
+       public void setContactComment (final String contactComment) {
+               this.contactComment = contactComment;
+       }
+
+       @Override
+       public Country getContactCountry () {
+               return this.contactCountry;
+       }
+
+       @Override
+       public void setContactCountry (final Country contactCountry) {
+               this.contactCountry = contactCountry;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Calendar getContactCreated () {
+               return this.contactCreated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setContactCreated (final Calendar contactCreated) {
+               this.contactCreated = contactCreated;
+       }
+
+       @Override
+       public String getContactEmailAddress () {
+               return this.contactEmailAddress;
+       }
+
+       @Override
+       public void setContactEmailAddress (final String contactEmailAddress) {
+               this.contactEmailAddress = contactEmailAddress;
+       }
+
+       @Override
+       public String getContactFamilyName () {
+               //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
+               return this.contactFamilyName;
+       }
+
+       @Override
+       public void setContactFamilyName (final String contactFamilyName) {
+               this.contactFamilyName = contactFamilyName;
+       }
+
+       @Override
+       public DialableFaxNumber getContactFaxNumber () {
+               return this.contactFaxNumber;
+       }
+
+       @Override
+       public void setContactFaxNumber (final DialableFaxNumber contactFaxNumber) {
+               this.contactFaxNumber = contactFaxNumber;
+       }
+
+       @Override
+       public String getContactFirstName () {
+               return this.contactFirstName;
+       }
+
+       @Override
+       public void setContactFirstName (final String contactFirstName) {
+               this.contactFirstName = contactFirstName;
+       }
+
+       @Override
+       public Short getContactHouseNumber () {
+               return this.contactHouseNumber;
+       }
+
+       @Override
+       public void setContactHouseNumber (final Short contactHouseNumber) {
+               this.contactHouseNumber = contactHouseNumber;
+       }
+
+       @Override
+       public String getContactHouseNumberExtension () {
+               return this.contactHouseNumberExtension;
+       }
+
+       @Override
+       public void setContactHouseNumberExtension (final String contactHouseNumberExtension) {
+               this.contactHouseNumberExtension = contactHouseNumberExtension;
+       }
+
+       @Override
+       public Long getContactId () {
+               return this.contactId;
+       }
+
+       @Override
+       public void setContactId (final Long contactId) {
+               this.contactId = contactId;
+       }
+
+       @Override
+       public DialableLandLineNumber getContactLandLineNumber () {
+               return this.contactPhoneNumber;
+       }
+
+       @Override
+       public void setContactLandLineNumber (final DialableLandLineNumber contactPhoneNumber) {
+               this.contactPhoneNumber = contactPhoneNumber;
+       }
+
+       @Override
+       public DialableMobileNumber getContactMobileNumber () {
+               return this.contactMobileNumber;
+       }
+
+       @Override
+       public void setContactMobileNumber (final DialableMobileNumber contactMobileNumber) {
+               this.contactMobileNumber = contactMobileNumber;
+       }
+
+       @Override
+       public void setContactOwnContact (final Boolean contactOwnContact) {
+               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;
+       }
+
+       @Override
+       public void setContactStreet (final String contactStreet) {
+               this.contactStreet = contactStreet;
+       }
+
+       @Override
+       public String getContactTitle () {
+               return this.contactTitle;
+       }
+
+       @Override
+       public void setContactTitle (final String contactTitle) {
+               this.contactTitle = contactTitle;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Calendar getContactUpdated () {
+               return this.contactUpdated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setContactUpdated (final Calendar contactUpdated) {
+               this.contactUpdated = contactUpdated;
+       }
+
+       @Override
+       public Integer getContactZipCode () {
+               return this.contactZipCode;
+       }
+
+       @Override
+       public void setContactZipCode (final Integer contactZipCode) {
+               this.contactZipCode = contactZipCode;
+       }
+
+       @Override
+       public int hashCode () {
+               int hash = 5;
+
+               hash = 29 * hash + Objects.hashCode(this.getContactBirthday());
+               hash = 29 * hash + Objects.hashCode(this.getContactCity());
+               hash = 29 * hash + Objects.hashCode(this.getContactCountry());
+               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.getContactPersonalTitle());
+               hash = 29 * hash + Objects.hashCode(this.getContactHouseNumber());
+               hash = 29 * hash + Objects.hashCode(this.getContactHouseNumberExtension());
+               hash = 29 * hash + Objects.hashCode(this.getContactId());
+               hash = 29 * hash + Objects.hashCode(this.getContactStreet());
+               hash = 29 * hash + Objects.hashCode(this.getContactTitle());
+
+               return hash;
+       }
+
+       @Override
+       public Boolean isOwnContact () {
+               return this.contactOwnContact;
+       }
+
+}
diff --git a/src/org/mxchange/jcontacts/model/contact/gender/Gender.java b/src/org/mxchange/jcontacts/model/contact/gender/Gender.java
new file mode 100644 (file)
index 0000000..3af0329
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.model.contact.gender;
+
+import java.io.Serializable;
+
+/**
+ * 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 gender
+        */
+       MALE('M', "GENDER_MALE"), //NOI18N
+
+       /**
+        * Female gender
+        */
+       FEMALE('F', "GENDER_FEMALE"); //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 Gender (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;
+       }
+
+}
diff --git a/src/org/mxchange/jcontacts/model/contact/gender/GenderUtils.java b/src/org/mxchange/jcontacts/model/contact/gender/GenderUtils.java
new file mode 100644 (file)
index 0000000..5156db7
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * 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.model.contact.gender;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Gender utils class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class GenderUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 185_683_479_107L;
+
+       /**
+        * Cache for valid chars
+        */
+       private static char[] validChars;
+
+       /**
+        * All available genders as a list
+        * <p>
+        * @return Selectable genders (not UNKNOWN)
+        */
+       public static List<Gender> allGendersAsList () {
+               // Init list
+               List<Gender> list = new LinkedList<>();
+
+               // Walk through all genders
+               for (final Gender gender : Gender.values()) {
+                       // Add it and check if it has been added
+                       list.add(gender);
+               }
+
+               // Return it
+               return list;
+       }
+
+       /**
+        * 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 () {
+       }
+
+}
diff --git a/src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java b/src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java
new file mode 100644 (file)
index 0000000..ee8c343
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.model.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;
+       }
+
+}
diff --git a/src/org/mxchange/jcontacts/model/contact/title/TitleUtils.java b/src/org/mxchange/jcontacts/model/contact/title/TitleUtils.java
new file mode 100644 (file)
index 0000000..60b1f56
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * 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.model.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
+        * @deprecated Arrays.asList() is there
+        */
+       @Deprecated
+       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 () {
+       }
+
+}