Package com.tangosol.util.comparator
Class PriorityComparator<T>
- java.lang.Object
-
- com.tangosol.util.comparator.PriorityComparator<T>
-
- Type Parameters:
T
- the type to be ordered
- All Implemented Interfaces:
Comparator<T>
public class PriorityComparator<T> extends Object implements Comparator<T>
AComparator
that orders values that are annotated with thePriority
annotation.- Since:
- 22.06
- Author:
- Jonathan Knight 2022.05.25
-
-
Constructor Summary
Constructors Constructor Description PriorityComparator(Function<T,javax.annotation.Priority> function, int nDefault)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(T o1, T o2)
static <S> Comparator<ServiceLoader.Provider<S>>
forServiceLoader()
Returns aComparator
that can sortServiceLoader.Provider
instances based on whether the class they provide is annotated with thePriority
annotation.Comparator<T>
reversed()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
compare
public int compare(T o1, T o2)
- Specified by:
compare
in interfaceComparator<T>
-
forServiceLoader
public static <S> Comparator<ServiceLoader.Provider<S>> forServiceLoader()
Returns aComparator
that can sortServiceLoader.Provider
instances based on whether the class they provide is annotated with thePriority
annotation.- Type Parameters:
S
- the type of service provided- Returns:
- a
Comparator
to sortPriority
annotatedServiceLoader.Provider
instances
-
reversed
public Comparator<T> reversed()
- Specified by:
reversed
in interfaceComparator<T>
-
-