]> git.mxchange.org Git - juser-activity-core.git/commitdiff
added method getAllUserFields() to return almost all user's fields, including some...
authorRoland Häder <roland@mxchange.org>
Tue, 17 May 2016 13:14:18 +0000 (15:14 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 17 May 2016 13:14:18 +0000 (15:14 +0200)
src/org/mxchange/jusercore/model/user/UserUtils.java

index 8aa0b11f455c8a739c125ac84cc6ba7bdcbc90e1..18b1b332d896fe756b7c413f695d399ec1024a9c 100644 (file)
@@ -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.
+        * <p>
+        * @param user User instance to get all fields from
+        * <p>
+        * @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
         * <p>