@Test public void testCompareToWithSameDeadlines() { int deadline = 1000; TaskImpl task1 = new TaskImpl(deadline, 1); TaskImpl task2 = new TaskImpl(deadline, 2); Assert.assertTrue("Expected task1 to order 'less' due to being created first", task1.compareTo(task2) < 0); Assert.assertTrue("Expected task2 to order 'greater' due to being created second", task1.compareTo(task2) < 0); Assert.assertTrue(task2.compareTo(task1) > 0); }
@Override public int compareTo(TaskImpl other) { int result; if (deadline < other.deadline) { result = -1; } else if (deadline > other.deadline) { result = 1; } else { result = counter - other.counter; } return result; }
TaskImpl implements Task, Comparable<TaskImpl> { @Override public int compareTo(TaskImpl other) { int result; if (deadline < other.deadline) { result = -1; } else if (deadline > other.deadline) { result = 1; } else { result = counter - other.counter; } return result; } }
TaskImpl implements Task, Comparable<TaskImpl> { @Override public int compareTo(TaskImpl other) { int result; if (deadline < other.deadline) { result = -1; } else if (deadline > other.deadline) { result = 1; } else { result = counter - other.counter; } return result; } TaskImpl(long deadline, int counter); }
TaskImpl implements Task, Comparable<TaskImpl> { @Override public int compareTo(TaskImpl other) { int result; if (deadline < other.deadline) { result = -1; } else if (deadline > other.deadline) { result = 1; } else { result = counter - other.counter; } return result; } TaskImpl(long deadline, int counter); @Override int compareTo(TaskImpl other); @Override long deadline(); boolean isCancelled(); @Override void cancel(); void setReactor(Reactor reactor); @Override Reactor getReactor(); @Override Record attachments(); }
TaskImpl implements Task, Comparable<TaskImpl> { @Override public int compareTo(TaskImpl other) { int result; if (deadline < other.deadline) { result = -1; } else if (deadline > other.deadline) { result = 1; } else { result = counter - other.counter; } return result; } TaskImpl(long deadline, int counter); @Override int compareTo(TaskImpl other); @Override long deadline(); boolean isCancelled(); @Override void cancel(); void setReactor(Reactor reactor); @Override Reactor getReactor(); @Override Record attachments();  }