Package com.globalmentor.model
Class ValuedComparator<V extends Comparable<V>>
java.lang.Object
com.globalmentor.collections.comparators.AbstractSortOrderComparator<Valued<V>>
com.globalmentor.model.ValuedComparator<V>
- Type Parameters:
V
- The type of value contained in the valued objects
- All Implemented Interfaces:
SortOrderComparator<Valued<V>>
,Comparator<Valued<V>>
public class ValuedComparator<V extends Comparable<V>>
extends AbstractSortOrderComparator<Valued<V>>
Comparator that sorts two
Valued
objects by their comparable values.
This comparator supports null
values.
- Author:
- Garret Wilson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
compareImpl
(Valued<V> object1, Valued<V> object2) Implementation to compare two objects for order.Methods inherited from class com.globalmentor.collections.comparators.AbstractSortOrderComparator
compare, getSortOrder
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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
ValuedComparator
Sort order constructor.- Parameters:
sortOrder
- The order in which to perform comparisons.- Throws:
NullPointerException
- if the given sort order isnull
.
-
-
Method Details
-
compareImpl
Implementation to compare two objects for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. Implementations do not need to perform special checks for identity, as theAbstractSortOrderComparator.compare(Object, Object)
implementation will do this.- Specified by:
compareImpl
in classAbstractSortOrderComparator<Valued<V extends Comparable<V>>>
- Parameters:
object1
- The first object to be compared.object2
- The second object to be compared.- Returns:
- A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- See Also:
-