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