]> git.mxchange.org Git - juser-activity-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 21 Jan 2023 20:33:27 +0000 (21:33 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 21 Jan 2023 20:33:27 +0000 (21:33 +0100)
- added checks for parameters of public method
- tpzo fixed

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

index 09627d6f6fd937088aac60dd0133a8c9f1d11551..87d1b75d8c2195cb24d2395cac1326627e6e91d1 100644 (file)
@@ -252,7 +252,7 @@ public class UserActivityLog implements LogableUserActivity {
         * <p>
         * @param activityType      Type
         * @param activityUser      User instance
-        * @param activityTimestamp imestamp
+        * @param activityTimestamp Timestamp
         * @param principalName     Principal name
         */
        public UserActivityLog (final String activityType, final User activityUser, final Date activityTimestamp, final String principalName) {
index 09fd503f6ad3b220f0be6b77fc27e9e60eeed719..0885fa1217e4f52fa22575ca0b4c8a5155bc0b86 100644 (file)
@@ -28,6 +28,16 @@ public class UserActivityLogTimestampComparator implements Comparator<LogableUse
 
        @Override
        public int compare (final LogableUserActivity userActivity1, final LogableUserActivity userActivity2) {
+               // Check if both parameters are given or below statement will cause a NPE
+               if (null == userActivity1) {
+                       // Throw NPE
+                       throw new NullPointerException("Parameter 'userActivity1' is null"); //NOI18N
+               } else if (null == userActivity2) {
+                       // Throw NPE
+                       throw new NullPointerException("Parameter 'userActivity2' is null"); //NOI18N
+               }
+
+               // Check all conditions
                return (userActivity1.getActivityTimestamp().getTime() < userActivity2.getActivityTimestamp().getTime() ? -1 : userActivity1.getActivityTimestamp().getTime() == userActivity2.getActivityTimestamp().getTime() ? 0 : 1);
        }