]> git.mxchange.org Git - juser-activity-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 5 Nov 2022 08:24:14 +0000 (09:24 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 5 Nov 2022 08:24:14 +0000 (09:24 +0100)
- invoke other (lesser/no parameter) constructor to avoid side effects
- checked on parameters of a constructor

src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java

index 4052caf4e6758dbce62ff482a027feb200e4ac88..09627d6f6fd937088aac60dd0133a8c9f1d11551 100644 (file)
@@ -149,7 +149,7 @@ public class UserActivityLog implements LogableUserActivity {
         * @param activityMessage   Message
         * @param activityType      Type
         * @param activityUser      User instance
-        * @param activityTimestamp imestamp
+        * @param activityTimestamp Timestamp
         */
        public UserActivityLog (final String activityMessage, final String activityType, final User activityUser, final Date activityTimestamp) {
                // Call other constructor
@@ -173,9 +173,12 @@ public class UserActivityLog implements LogableUserActivity {
         * <p>
         * @param activityType      Type
         * @param activityUser      User instance
-        * @param activityTimestamp imestamp
+        * @param activityTimestamp Timestamp
         */
        public UserActivityLog (final String activityType, final User activityUser, final Date activityTimestamp) {
+               // Invoke oher constructor
+               this();
+
                // Make sure all is set
                if (null == activityType) {
                        // Throw NPE
@@ -231,6 +234,15 @@ public class UserActivityLog implements LogableUserActivity {
                // Call other constructor
                this(activityMessage, activityType, activityUser, activityTimestamp);
 
+               // Validater parameter
+               if (null == principalName) {
+                       // Throw NPE
+                       throw new NullPointerException("principalName is null"); //NOI18N
+               } else if (principalName.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("principalName is empty"); //NOI18N
+               }
+
                // Set principal name
                this.activityPrincipalName = principalName;
        }
@@ -247,6 +259,15 @@ public class UserActivityLog implements LogableUserActivity {
                // Call other constructor
                this(activityType, activityUser, activityTimestamp);
 
+               // Validater parameter
+               if (null == principalName) {
+                       // Throw NPE
+                       throw new NullPointerException("principalName is null"); //NOI18N
+               } else if (principalName.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("principalName is empty"); //NOI18N
+               }
+
                // Set principal name
                this.activityPrincipalName = principalName;
        }