summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-19 15:26:09 +0200
committerSimon Rettberg2015-08-19 15:26:09 +0200
commite1316b46c190a3e2ad6b1b04ec6fbd103c4d5146 (patch)
tree5cd46e5fc1d1a6e598cc60b0931fc9ef98f6fbeb /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java
parent[client] F5 = refresh in lecture and image list (diff)
downloadtutor-module-e1316b46c190a3e2ad6b1b04ec6fbd103c4d5146.tar.gz
tutor-module-e1316b46c190a3e2ad6b1b04ec6fbd103c4d5146.tar.xz
tutor-module-e1316b46c190a3e2ad6b1b04ec6fbd103c4d5146.zip
[client] Clean up sorting logic of image and lecture table
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java
new file mode 100644
index 00000000..8a0559f2
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java
@@ -0,0 +1,51 @@
+package org.openslx.dozmod.thrift;
+
+import java.util.Comparator;
+
+import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.bwlp.thrift.iface.UserInfo;
+import org.openslx.dozmod.thrift.cache.MetaDataCache;
+import org.openslx.dozmod.thrift.cache.UserCache;
+import org.openslx.dozmod.util.FormatHelper;
+
+/**
+ * Collection of comparators targeted at sorting different objects in a
+ * human-suitable way (e.g. sort users by their display name)
+ */
+public class Sorters {
+
+ public static final Comparator<UserInfo> userName = new Comparator<UserInfo>() {
+ @Override
+ public int compare(UserInfo o1, UserInfo o2) {
+ return FormatHelper.userName(o1).compareTo(FormatHelper.userName(o2));
+ }
+ };
+
+ public static final Comparator<String> userNameById = new Comparator<String>() {
+ @Override
+ public int compare(String o1, String o2) {
+ return userName.compare(UserCache.find(o1), UserCache.find(o2));
+ }
+ };
+
+ public static final Comparator<OperatingSystem> osName = new Comparator<OperatingSystem>() {
+ @Override
+ public int compare(OperatingSystem o1, OperatingSystem o2) {
+ return FormatHelper.osName(o1).compareTo(FormatHelper.osName(o2));
+ }
+ };
+
+ public static final Comparator<Integer> osNameById = new Comparator<Integer>() {
+ @Override
+ public int compare(Integer o1, Integer o2) {
+ if (o1 == null) {
+ o1 = 0;
+ }
+ if (o2 == null) {
+ o2 = 0;
+ }
+ return osName.compare(MetaDataCache.getOsById(o1), MetaDataCache.getOsById(o2));
+ }
+ };
+
+}