From: Roland Häder Date: Fri, 3 Jun 2016 07:41:24 +0000 (+0200) Subject: Thumb of a rule: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f67911d2934adfe8a9b5b4f46753a7a24a0dd513;p=jcontacts-core.git Thumb of a rule: - don't set default values, let it fail with an NPE if not taken correctly care of. - if a default value is set, the mistake of careless will be spotted very much later (e.g. when the data is already persisted). - if no default value is set (in this case it makes sense not set ...) an NPE is likely be thrown which might be spotted much earlier. - this is good as bugs/bad data are detected (prevented in the end) earlier, too. --- diff --git a/src/org/mxchange/jcontacts/contact/UserContact.java b/src/org/mxchange/jcontacts/contact/UserContact.java index 3312c8f..c4f6ba7 100644 --- a/src/org/mxchange/jcontacts/contact/UserContact.java +++ b/src/org/mxchange/jcontacts/contact/UserContact.java @@ -226,9 +226,6 @@ public class UserContact implements Contact { public UserContact () { // Default is not user's own contact this.contactOwnContact = Boolean.FALSE; - - // Unknown gender - this.contactGender = Gender.UNKNOWN; } /** diff --git a/src/org/mxchange/jcontacts/contact/gender/Gender.java b/src/org/mxchange/jcontacts/contact/gender/Gender.java index 62da233..890eb93 100644 --- a/src/org/mxchange/jcontacts/contact/gender/Gender.java +++ b/src/org/mxchange/jcontacts/contact/gender/Gender.java @@ -26,11 +26,6 @@ import java.text.MessageFormat; */ public enum Gender implements Serializable { - /** - * Unknown enum - */ - UNKNOWN('U', "GENDER_UNKNOWN"), //NOI18N - /** * Male enum */ diff --git a/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java b/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java index ab2fd59..b8ec349 100644 --- a/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java +++ b/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java @@ -44,14 +44,8 @@ public class GenderUtils implements Serializable { // Walk through all genders for (final Gender gender : Gender.values()) { - // Is it not UNKNOWN - if (!gender.equals(Gender.UNKNOWN)) { - // Add it - boolean added = list.add(gender); - - // Has it been added? - assert (added) : MessageFormat.format("gender {0} not added.", gender); //NOI18N - } + // Add it and check if it has been added + assert (list.add(gender)) : MessageFormat.format("gender {0} not added.", gender); //NOI18N } // Return it