From: Roland Häder Date: Sat, 5 Nov 2022 08:24:14 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8fdc52ba56dc8ef5407dd5c995b217fbe148c5ed;p=juser-activity-core.git Continued: - invoke other (lesser/no parameter) constructor to avoid side effects - checked on parameters of a constructor --- diff --git a/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java b/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java index 4052caf..09627d6 100644 --- a/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java +++ b/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java @@ -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 { *

* @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; }