import java.util.LinkedList;
import java.util.List;
import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcore.model.contact.Contact;
/**
* Gender utils class
* @author Roland Haeder<roland@mxchange.org>
*/
public class GenderUtils extends BaseFrameworkSystem {
+
+ /**
+ * Translates contact's gender to human-readable
+ *
+ * @param contact Contact instance
+ * @return Translates value (from bundle)
+ */
+ public static String getTranslatedGender (final Contact contact) {
+ // Init instance
+ GenderUtils utils = new GenderUtils();
+
+ // Trace message
+ utils.getLogger().trace(MessageFormat.format("getTranslatedGender: contact={0} - CALLED!", contact));
+
+ // contact must be set
+ if (null == contact) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ } else if (contact.getGender() == null) {
+ // Gender is not set
+ throw new NullPointerException(MessageFormat.format("contact {0} has no gender set.", contact));
+ }
+
+ // Get key from it
+ String key = contact.getGender().getMessageKey();
+
+ // Debug message
+ utils.getLogger().debug(MessageFormat.format("getTranslatedGender: key={0}", key));
+
+ // Translate and return it
+ return utils.getMessageStringFromKey(key);
+ }
+
/**
* Private contructor as this is an utility class
*/
/**
* All selectable genders (not UNKNOWN)
- *
+ *
* @return Selectable genders (not UNKNOWN)
*/
public static List<Gender> selectableGenders () {
boolean added = list.add(gender);
// Has it been added?
- assert(added) : MessageFormat.format("gender {0} not added.", gender); //NOI18N
+ assert (added) : MessageFormat.format("gender {0} not added.", gender); //NOI18N
}
}