From: Roland Häder Date: Tue, 17 May 2016 13:14:18 +0000 (+0200) Subject: added method getAllUserFields() to return almost all user's fields, including some... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b48df3b1c7ad02fe984b25fdc9ea13c6acd2962b;p=juser-activity-core.git added method getAllUserFields() to return almost all user's fields, including some contact data --- diff --git a/src/org/mxchange/jusercore/model/user/UserUtils.java b/src/org/mxchange/jusercore/model/user/UserUtils.java index 8aa0b11..18b1b33 100644 --- a/src/org/mxchange/jusercore/model/user/UserUtils.java +++ b/src/org/mxchange/jusercore/model/user/UserUtils.java @@ -19,6 +19,7 @@ package org.mxchange.jusercore.model.user; import java.io.Serializable; import java.security.SecureRandom; import java.text.MessageFormat; +import java.util.Properties; import java.util.Random; import org.apache.commons.codec.digest.Crypt; import org.apache.commons.codec.digest.DigestUtils; @@ -191,6 +192,49 @@ public class UserUtils implements Serializable { return hash; } + /** + * Returns a Properties object from given user instance. + *

+ * @param user User instance to get all fields from + *

+ * @return All properties from given user + */ + public static Properties getAllUserFields (final User user) { + // Parameter should be valid + if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); + } + + // Init properties list + Properties properties = new Properties(); + + // Set all: + // - User data + properties.setProperty("userId", Long.toString(user.getUserId())); + properties.setProperty("userName", user.getUserName()); + properties.setProperty("userConfirmKey", user.getUserConfirmKey()); + properties.setProperty("userLastLockedReason", user.getUserLastLockedReason()); + properties.setProperty("userAccountStatus", user.getUserAccountStatus().toString()); + + // - Contact data + properties.setProperty("contactGender", user.getUserContact().getContactGender().toString()); + properties.setProperty("contactTitle", user.getUserContact().getContactTitle()); + properties.setProperty("contactFirstName", user.getUserContact().getContactFirstName()); + properties.setProperty("contactFamilyName", user.getUserContact().getContactFamilyName()); + properties.setProperty("contactStreet", user.getUserContact().getContactStreet()); + properties.setProperty("contactHouseNumber", Short.toString(user.getUserContact().getContactHouseNumber())); + properties.setProperty("contacCity", user.getUserContact().getContactCity()); + properties.setProperty("contactZipCode", Integer.toString(user.getUserContact().getContactZipCode())); + properties.setProperty("contactBirthday", user.getUserContact().getContactBirthday().toString()); + properties.setProperty("contactEmailAddress", user.getUserContact().getContactEmailAddress()); + properties.setProperty("contactCreated", user.getUserContact().getContactCreated().toString()); + properties.setProperty("contactUpdated", user.getUserContact().getContactUpdated().toString()); + + // Return it + return properties; + } + /** * Checks if password from container matches the updatedUser's password *