- Type Parameters:
R
- the type of resources (e.g.Feature
) to sort.
- All Superinterfaces:
Comparator<R>
Properties whose values shall be used to order the set of resources that satisfy a filter expression.
SortBy
provides an entry point to invoke the sorting mechanism of the filter expression processor.
The sorting mechanism is not specified. The only requirement is that the sort sequence shall be consistent,
given the same data set and sort request, between consecutive invocations of the sort.- Since:
- 3.1
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
Compares two resources for order.The properties whose values are used for sorting.Methods inherited from interface Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
getSortProperties
@UML(identifier="sortProperty", obligation=MANDATORY, specification=ISO_19143) List<SortProperty<R>> getSortProperties()The properties whose values are used for sorting. The list shall have a minimum of one element. In the event that multiple elements exist, the sequence of theSortProperty
elements determines the order of ordering.- Returns:
- properties whose values are used for sorting.
-
compare
Compares two resources for order. Returns a negative number ifr1
should be sorted beforer2
, a positive number ifr2
should be afterr1
, or 0 if both resources are equal. The ordering of null resources or null property values is unspecified.The comparison shall be consistent (ignoring unspecified aspects such as null values) with a comparison done "manually" by the following code:
for (SortProperty<R> p : getSortProperties()) { int c = p.compare(r1, r2); if (c != 0) return c; } return 0;
In order words, it shall be possible for the users to build their own SQL (or other language) query using above information and get the same results without invoking this
compare(…)
method.- Specified by:
compare
in interfaceComparator<R>
- Parameters:
r1
- the first resource to compare.r2
- the second resource to compare.- Returns:
- negative if the first resource is before the second, positive for the converse, or 0 if equal.
- Throws:
InvalidFilterValueException
- if an expression cannot be applied on the given resources.ClassCastException
- if the types of property values prevent them from being compared by this comparator.- See Also:
-