From: Roland Häder Date: Sun, 22 Jan 2023 00:37:13 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5a506c6dd7e45d3c59ee86534e7d4b1dfbb60a02;p=jcontacts-core.git Continued: - moved utilities class into own package --- diff --git a/src/org/mxchange/jcontacts/model/contact/gender/GenderUtils.java b/src/org/mxchange/jcontacts/model/contact/gender/GenderUtils.java deleted file mode 100644 index d0a7f82..0000000 --- a/src/org/mxchange/jcontacts/model/contact/gender/GenderUtils.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2016 - 2022 Free Software Foundation - * - * 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 . - */ -package org.mxchange.jcontacts.model.contact.gender; - -import java.io.Serializable; -import java.text.MessageFormat; - -/** - * Gender utilities class - *

- * @author Roland Häder - */ -public class GenderUtils implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 185_683_479_107L; - - /** - * Cache for valid chars - */ - private static char[] validChars; - - /** - * Getter for Gender enumeration from given character - *

- * @param c Gender character - *

- * @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) - *

- * @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/utils/ContactUtils.java b/src/org/mxchange/jcontacts/model/utils/ContactUtils.java index 0a70b10..8df677f 100644 --- a/src/org/mxchange/jcontacts/model/utils/ContactUtils.java +++ b/src/org/mxchange/jcontacts/model/utils/ContactUtils.java @@ -148,7 +148,7 @@ public class ContactUtils implements Serializable { } /** - * Updates land-line data in contact instance. This method also removes the + * Updates fax number 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. diff --git a/src/org/mxchange/jcontacts/model/utils/GenderUtils.java b/src/org/mxchange/jcontacts/model/utils/GenderUtils.java new file mode 100644 index 0000000..db3b339 --- /dev/null +++ b/src/org/mxchange/jcontacts/model/utils/GenderUtils.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2016 - 2022 Free Software Foundation + * + * 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 . + */ +package org.mxchange.jcontacts.model.utils; + +import java.io.Serializable; +import java.text.MessageFormat; +import org.mxchange.jcontacts.model.contact.gender.Gender; + +/** + * Gender utilities class + *

+ * @author Roland Häder + */ +public class GenderUtils implements Serializable { + + /** + * Serial number + */ + private static final long serialVersionUID = 185_683_479_107L; + + /** + * Cache for valid chars + */ + private static char[] validChars; + + /** + * Getter for Gender enumeration from given character + *

+ * @param c Gender character + *

+ * @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) + *

+ * @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 () { + } + +}