Переглянути джерело

QueueHandler now implements Comparator<QueueItem>

tags/0.6.3
Shane Mc Cormack 15 роки тому
джерело
коміт
b2631eb9a9

+ 3
- 2
src/com/dmdirc/parser/irc/outputqueue/QueueHandler.java Переглянути файл

24
 
24
 
25
 import com.dmdirc.parser.common.QueuePriority;
25
 import com.dmdirc.parser.common.QueuePriority;
26
 import java.io.PrintWriter;
26
 import java.io.PrintWriter;
27
+import java.util.Comparator;
27
 import java.util.concurrent.BlockingQueue;
28
 import java.util.concurrent.BlockingQueue;
28
 
29
 
29
 /**
30
 /**
31
  *
32
  *
32
  * @author shane
33
  * @author shane
33
  */
34
  */
34
-public abstract class QueueHandler extends Thread {
35
+public abstract class QueueHandler extends Thread implements Comparator<QueueItem> {
35
     /** Queue we are handling. */
36
     /** Queue we are handling. */
36
     protected final BlockingQueue<QueueItem> queue;
37
     protected final BlockingQueue<QueueItem> queue;
37
 
38
 
96
      * @param otherObject Object we are comparing to.
97
      * @param otherObject Object we are comparing to.
97
      * @return A QueueItem for teh given parameters
98
      * @return A QueueItem for teh given parameters
98
      */
99
      */
99
-    public int compareQueueItem(final QueueItem mainObject, final QueueItem otherObject) {
100
+    public int compare(final QueueItem mainObject, final QueueItem otherObject) {
100
         if (mainObject.getTime() < 10 * 1000 && mainObject.getPriority().compareTo(otherObject.getPriority()) != 0) {
101
         if (mainObject.getTime() < 10 * 1000 && mainObject.getPriority().compareTo(otherObject.getPriority()) != 0) {
101
             return mainObject.getPriority().compareTo(otherObject.getPriority());
102
             return mainObject.getPriority().compareTo(otherObject.getPriority());
102
         }
103
         }

+ 1
- 1
src/com/dmdirc/parser/irc/outputqueue/QueueItem.java Переглянути файл

109
      */
109
      */
110
     @Override
110
     @Override
111
     public int compareTo(final QueueItem o) {
111
     public int compareTo(final QueueItem o) {
112
-        return handler.compareQueueItem(this, o);
112
+        return handler.compare(this, o);
113
     }
113
     }
114
 
114
 
115
     /** {@inheritDoc} */
115
     /** {@inheritDoc} */

+ 2
- 2
src/com/dmdirc/parser/irc/outputqueue/SimpleRateLimitedQueueHandler.java Переглянути файл

182
      * used.
182
      * used.
183
      */
183
      */
184
     @Override
184
     @Override
185
-    public int compareQueueItem(final QueueItem mainObject, final QueueItem otherObject) {
185
+    public int compare(final QueueItem mainObject, final QueueItem otherObject) {
186
         if (mainObject.getPriority().compareTo(otherObject.getPriority()) != 0) {
186
         if (mainObject.getPriority().compareTo(otherObject.getPriority()) != 0) {
187
             return mainObject.getPriority().compareTo(otherObject.getPriority());
187
             return mainObject.getPriority().compareTo(otherObject.getPriority());
188
         } else {
188
         } else {
189
-            return super.compareQueueItem(mainObject, otherObject);
189
+            return super.compare(mainObject, otherObject);
190
         }
190
         }
191
     }
191
     }
192
 
192
 

Завантаження…
Відмінити
Зберегти