@Test public void testCompare() { ServiceReference low = new MockLowPriorityServiceReference(); ServiceReference nullPriority = new MockServiceReference(); ServiceReference high = new MockHighPriorityServiceReference(); OSGIServiceComparator instance = new OSGIServiceComparator(); assertThat(1).isEqualTo(instance.compare(low, high)); assertThat(-1).isEqualTo(instance.compare(high, low)); assertThat(0).isEqualTo(instance.compare(low, low)); assertThat(1).isEqualTo(instance.compare(nullPriority, high)); assertThat(-1).isEqualTo(instance.compare(high, nullPriority)); assertThat(0).isEqualTo(instance.compare(nullPriority, low)); }
@Override public int compare(ServiceReference o1, ServiceReference o2) { int prio = getPriority(o1) - getPriority(o2); if (prio < 0) { return 1; } else if (prio > 0) { return -1; } else { return 0; } }
OSGIServiceComparator implements Comparator<ServiceReference> { @Override public int compare(ServiceReference o1, ServiceReference o2) { int prio = getPriority(o1) - getPriority(o2); if (prio < 0) { return 1; } else if (prio > 0) { return -1; } else { return 0; } } }
OSGIServiceComparator implements Comparator<ServiceReference> { @Override public int compare(ServiceReference o1, ServiceReference o2) { int prio = getPriority(o1) - getPriority(o2); if (prio < 0) { return 1; } else if (prio > 0) { return -1; } else { return 0; } }  }
OSGIServiceComparator implements Comparator<ServiceReference> { @Override public int compare(ServiceReference o1, ServiceReference o2) { int prio = getPriority(o1) - getPriority(o2); if (prio < 0) { return 1; } else if (prio > 0) { return -1; } else { return 0; } }  @Override int compare(ServiceReference o1, ServiceReference o2); static int getPriority(Object o); static int getPriority(Class<? extends Object> type); }
OSGIServiceComparator implements Comparator<ServiceReference> { @Override public int compare(ServiceReference o1, ServiceReference o2) { int prio = getPriority(o1) - getPriority(o2); if (prio < 0) { return 1; } else if (prio > 0) { return -1; } else { return 0; } }  @Override int compare(ServiceReference o1, ServiceReference o2); static int getPriority(Object o); static int getPriority(Class<? extends Object> type);  }