From beecc0e70232e66bf81c6b16c4bb70f722047866 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 26 Aug 2016 11:24:46 +0200 Subject: [PATCH] Continued a bit: - added comparator for comparing timestamps - fixed copyright/author --- .../user/activity/LogableUserActivity.java | 4 +-- .../model/user/activity/UserActivityLog.java | 4 +-- .../UserActivityLogTimestampComparator.java | 34 +++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/org/mxchange/jusercore/model/user/activity/comparator/UserActivityLogTimestampComparator.java diff --git a/src/org/mxchange/jusercore/model/user/activity/LogableUserActivity.java b/src/org/mxchange/jusercore/model/user/activity/LogableUserActivity.java index 252676c..ffd04fe 100644 --- a/src/org/mxchange/jusercore/model/user/activity/LogableUserActivity.java +++ b/src/org/mxchange/jusercore/model/user/activity/LogableUserActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Cho-Time GmbH + * Copyright (C) 2016 Roland Haeder * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ import org.mxchange.jusercore.model.user.User; /** * POJI for logable user activity *

- * @author Roland Haeder + * @author Roland Haeder */ public interface LogableUserActivity extends Serializable { diff --git a/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java b/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java index a1178e9..a0a0e3f 100644 --- a/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java +++ b/src/org/mxchange/jusercore/model/user/activity/UserActivityLog.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Cho-Time GmbH + * Copyright (C) 2016 Roland Haeder * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ import org.mxchange.jusercore.model.user.User; /** * A POJO for user acitivity log *

- * @author Roland Haeder + * @author Roland Haeder */ @Entity (name = "user_activity_log") @Table ( diff --git a/src/org/mxchange/jusercore/model/user/activity/comparator/UserActivityLogTimestampComparator.java b/src/org/mxchange/jusercore/model/user/activity/comparator/UserActivityLogTimestampComparator.java new file mode 100644 index 0000000..30424f1 --- /dev/null +++ b/src/org/mxchange/jusercore/model/user/activity/comparator/UserActivityLogTimestampComparator.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jusercore.model.user.activity.comparator; + +import java.util.Comparator; +import org.mxchange.jusercore.model.user.activity.LogableUserActivity; + +/** + * A comparator for comparing timestamps in user activity log + *

+ * @author Roland Haeder + */ +public class UserActivityLogTimestampComparator implements Comparator { + + @Override + public int compare (final LogableUserActivity userActivity1, final LogableUserActivity userActivity2) { + return (userActivity1.getActivityTimestamp().getTime().getTime() < userActivity2.getActivityTimestamp().getTime().getTime() ? -1 : userActivity1.getActivityTimestamp().getTime().getTime() == userActivity2.getActivityTimestamp().getTime().getTime() ? 0 : 1); + } + +} -- 2.39.5