From: David ‘Bombe’ Roden Date: Mon, 1 Nov 2010 20:31:20 +0000 (+0100) Subject: Add time comparator. X-Git-Tag: 0.2-RC1~74 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c0b6d5bd66aa0d1e6071c96afa24f31a2ec8ebc5;p=Sone.git Add time comparator. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Reply.java b/src/main/java/net/pterodactylus/sone/data/Reply.java index 05d8049..a106391 100644 --- a/src/main/java/net/pterodactylus/sone/data/Reply.java +++ b/src/main/java/net/pterodactylus/sone/data/Reply.java @@ -17,6 +17,7 @@ package net.pterodactylus.sone.data; +import java.util.Comparator; import java.util.UUID; /** @@ -27,6 +28,16 @@ import java.util.UUID; */ public class Reply { + /** Comparator that sorts replies ascending by time. */ + public static final Comparator TIME_COMPARATOR = new Comparator() { + + @Override + public int compare(Reply leftReply, Reply rightReply) { + return (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, leftReply.getTime() - rightReply.getTime())); + } + + }; + /** The ID of the reply. */ private final UUID id;